https://github.com/zenstackhq/nextjs-auth-postgres-template
https://github.com/zenstackhq/nextjs-auth-postgres-template
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zenstackhq/nextjs-auth-postgres-template
- Owner: zenstackhq
- License: mit
- Created: 2022-11-01T00:09:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T21:48:58.000Z (over 2 years ago)
- Last Synced: 2025-03-10T18:01:40.778Z (4 months ago)
- Language: TypeScript
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a starter project for using [ZenStack](https://github.com/zenstackhq/zenstack) with [Next.js](https://nextjs.org/) and [Next Auth](https://next-auth.js.org/).
It's extended from [Prisma's Next.js Starter](https://github.com/prisma/prisma-examples/tree/latest/typescript/rest-nextjs-api-routes).
## Getting Started
First create a project from this starter:
```bash
npx create-next-app [project-name] --use-npm -e https://github.com/zenstackhq/nextjs-auth-postgres-templatecd [project-name]
```Run ZenStack generator:
```
npm run generate
```Set a postgres connection string to DATABASE_URL in .env:
```
DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@[YOUR-URL]/postgres"
```Sync schema with database
```
npm run db:push
```Finally it's time to run your app locally:
```
npm run dev
```## Code Structure
### Data Model
The data model is located at [/zenstack/schema.zmodel](zenstack/schema.zmodel).
### Next-Auth Integration
You can find integration with Next-Auth at [/pages/api/auth/[...nextauth].ts](pages/api/auth/[...nextauth].ts).
### Mounted Data Services
The generated RESTful data access services are mounted at: [/pages/api/zenstack/[...path].ts](pages/api/zenstack/[...path].ts).
## Learn More
To learn more about ZenStack, take a look at the following resources:
- [ZenStack Documentation](https://github.com/zenstackhq/zenstack#readme)