This is an example implementation of a simple blog app using Next.js, TypeScript, Prisma, and GraphQL.
- ORM: Prisma
- client: Apollo Client
- server: Apollo Server
- server (Next.js integration): apollo-server-integration-next
- code generator: GraphQL Code Generator
- CSS framework: Tailwind CSS
In this example, the GraphQL server runs on the /api/graphql
endpoint of Next.js, and the frontend uses client side rendering (CSR).
If you want to use server side rendering (SSR), check this discussion.
This example uses the "app directory" system of Next.js.
For the "pages directory" system, implementation guide can be found here, for example.
Prerequisites: Node.js (>= v16), pnpm, Docker
- Install dependencies
pnpm install
- create
.env.local
file with the following content
DATABASE_URL="postgresql://postgres:admin@localhost:5432/postgres?schema=public"
- Make sure that you have Docker running, and then run the following command
pnpm dev
- Setup the database
pnpm setup:db
You can choose any hosting provider that supports Next.js and PostgreSQL.
For example, Vercel and Supabase are good choices.
When setting up DB in Supabase, you can follow this instruction.
After setting up the .env
file with DATABASE_URL
and SHADOW_DATABASE_URL
, run pnpm prisma migrate dev
to create tables.
Then, run pnpm prisma db seed
to add seed data.