Awesome
<h1 align="center"> Fullstack starter with next-auth, prisma, next.js and graphql-shield </h1>π Getting started
-
Setup a database.
Use the predefined
docker-compose.yml
configuration for localpostgres
instance.docker-compose up -d
<sub>don't forget about
.env
</sub>Also, you can use any DB supported by Prisma(docs)
-
Start developing.
Navigate into your new siteβs directory install modules and start it up.
npm i npm run dev
-
Open the source code and start editing!
Your site is now running at localhost:3000!
Open the
starter
directory in your code editor of choice and editsrc/pages/index.tsx
. Save your changes, and the browser will update in real-time!
ποΈ Database
Database toolkit
Starter use Prisma for db queries.
Migrations
-
Modify your schema file.
Open the
starter
directory in your code editor of choice and editprisma/schema.prisma
. Add Book model for example.model Book { id String @id @default(cuid()) title String authors User[] @relation(references: [id]) published Boolean @default(false) content String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
-
Generate migration files.
Use Prisma migrate tool.
prisma migrate dev --create-only --name init
You can find migration files in
prisma/migrations
. -
Apply migration.
Use Prisma migrate tool.
prisma migrate dev
-
Generate new fresh Prisma client.
npm run generate
More info about Prisma Migrate you can find in docs
π§ Auth
- Starter use next-auth - it's a complete open source authentication solution for Next.js applications.
- For graphql queries protection and auth rules you can use graphql-shield. Starter has a basic setup for it.
βοΈ Bundled instruments
Prisma studio
Prisma Studio is a visual editor for your database. Open prisma studio interface:
npm run studio
Graphql playground
Starter use ApolloServer and it's provide graphql-playground in dev
mode.
You can find it on localhost:3000/api/graphql
Apollo Client Devtools
Starter use Apollo Client and it's provide apollo-client-devtools in dev
mode.
To use it you need to install browser extension:
Download for Firefox | Download for Chrome
π ENV
Use .env.local
on production or .env.development
on dev. Read more
# Database
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/prisma?schema=public"
# Auth providers
AUTH_SECRET="this-is-a-secret-value-with-at-least-32-characters"
NEXTAUTH_URL="http://localhost:3000"
PROVIDER_GITHUB_ID=""
PROVIDER_GITHUB_SECRET=""
PROVIDER_SMTP_HOST=""
PROVIDER_SMTP_PORT=""
PROVIDER_SMTP_USER=""
PROVIDER_SMTP_PASSWORD=""
PROVIDER_SMTP_FROM=""
π« Deploy
Before deploy, you need to set up a database.