Back to templates

Template details

Next.js Apollo GraphQL MongoDB CRUD Starter

Starter for a generic CRUD app with Apollo GraphQL Server, Next.js API routes, and MongoDB.

About this template

The Next.js Apollo GraphQL MongoDB CRUD Starter is an open-source boilerplate that scaffolds a generic CRUD application with a Next.js front end, an Apollo GraphQL Server exposed as a Next.js API route, and MongoDB for data persistence; the repository carries the description "Advanced Starter GraphQL Next js Crud Mongodb" and has 31 stars.

What is this template?

This starter takes as input a MongoDB connection string stored in a .env.local file (renamed from .env.local.tmp) and produces a working GraphQL endpoint at /api/graphql, a generated TypeScript schema, and a home page at pages/index.tsx that you edit to build your UI. It runs entirely within the Next.js framework: the GraphQL server is implemented in pages/api/graphql.ts, so there is no separate backend process. The project is a create-next-app foundation, with API routes automatically mapped to /api/*.

Key Features

  • Next.js framework — Uses React-based Next.js with pages directory routing, including the home page at pages/index.tsx and API routes in pages/api.
  • Apollo GraphQL Server — The server lives in a single API route file, pages/api/graphql.ts, and can be tried at http://localhost:3000/api/graphql when the dev server runs.
  • MongoDB via environment variable — Database configuration is done by copying .env.local.tmp to .env.local and setting MONGODB_URI to a MongoDB connection URL.
  • Schema and TypeScript code generation — Running the yarn generate command builds the GraphQL schema and TypeScript type definitions so client and server types remain in sync.
  • Development server with hot reload — yarn dev starts Next.js in development mode; editing pages/index.tsx updates the page in the browser automatically.
  • Vercel deployment ready — The README links to the Vercel platform's one-click deployment flow for create-next-app projects, plus the standard Next.js deployment documentation.

Who is it for?

  • Next.js developers who want a preconfigured GraphQL API instead of wiring Apollo Server into an API route from scratch.
  • Full-stack teams building a CRUD product that needs MongoDB-backed GraphQL queries and mutations with generated TypeScript types.
  • Prototypers and learners who want a working GraphQL endpoint plus a minimal UI to experiment with, then replace pages/index.tsx with their own interface.

What can you do with it?

  • Backend developers: expose create, read, update, and delete operations as GraphQL mutations and queries over the /api/graphql endpoint without maintaining a separate GraphQL server process.
  • Frontend developers: use the generated TypeScript types to query real MongoDB data directly from Next.js pages or other GraphQL clients in the same project.
  • Educators: reference this boilerplate to see how Next.js API routes, Apollo GraphQL Server, and MongoDB fit together, matching the repository's topics of graphql-boilerplate, graphql-crud, and nextjs-graphql.

How does it work?

  1. Install dependencies with yarn install.
  2. Rename .env.local.tmp to .env.local and paste your MongoDB URI into MONGODB_URI.
  3. Run yarn generate to create the GraphQL schema and TypeScript types.
  4. Run yarn dev, then open http://localhost:3000/api/graphql to try the GraphQL endpoint.

FAQ

Is this starter free to use?

The repository is publicly hosted on GitHub and appears in search results as a boilerplate; nothing in the README indicates a paid license or pricing plan, so it is free to fork and modify.

What stack does this template use?

It uses Next.js (React framework), Apollo GraphQL Server (exposed through a Next.js API route), MongoDB (connected via a MONGODB_URI environment variable), and generates Typescript types with a yarn generate command.

How do I connect my MongoDB database?

Copy .env.local.tmp to .env.local, open the file, and replace the placeholder MONGODB_URI value with your actual MongoDB connection string. After saving, run yarn generate and then yarn dev.

Where is the GraphQL endpoint available?

During development, the GraphQL endpoint is at http://localhost:3000/api/graphql. It is defined in pages/api/graphql.ts, and because Next.js maps the pages/api directory to /api/*, the route is automatically exposed.

screenshot of Next.js Apollo GraphQL MongoDB CRUD Starter on template0.com