A lightweight Apollo Server integration for Next.js API routes. Current version 3.10.3 supports Node >=12, GraphQL 15/16, and Next.js 12+. Provides a simple `ApolloServerNext` class that plugs into Next.js pages/api handlers, handling CORS, body parsing, and error formatting. Unlike `apollo-server-micro` or standalone solutions, it's optimized for Next.js's serverless environment. Ships TypeScript types.
npm install apollo-server-nextjsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a minimal GraphQL API endpoint in a Next.js API route using ApolloServerNext and the handler helper.
Upgrade to Next.js >=12 and GraphQL >=15.
Add `export const config = { api: { bodyParser: false } };` in the API route file.Use a custom `context` function to set CORS headers or wrap handler with a CORS middleware.
Use `startServerAndCreateNextHandler(server)` instead.
Set `formatError` in ApolloServerNext config to avoid exposing stack traces.
Use `context: async ({ req, res }) => ({ req, res })`.Use `import { ApolloServerNext } from 'apollo-server-nextjs'` and configure your project for ESM.Export `startServerAndCreateNextHandler(server)` directly; do not wrap in another function.
Ensure `typeDefs` includes a `type Query { ... }` definition.