Serve
Deployment
Node.js Frameworks
Next.js

Integration with Next.js

💡

This page is currently under construction and expected to change. Please feel free to reach out to us directly in case you are having any troubles.

Next.js is a web framework that allows you to build websites very quickly and GraphQL Mesh can be integrated with Next.js easily as a custom route handler.

Example

// Next.js Custom Route Handler: https://nextjs.org/docs/app/building-your-application/routing/router-handlers
 
import { createServeRuntime } from '@graphql-mesh/serve-runtime'
 
const { handleRequest } = createServeRuntime({
  /* Your configuration here before the following required settings */
 
  // While using Next.js file convention for routing, we need to configure Mesh to use the correct endpoint
  graphqlEndpoint: '/api/graphql',
 
  // Mesh needs to know how to create a valid Next response
  fetchAPI: { Response }
})
 
// Export the handler to be used with the following HTTP methods
export { handleRequest as GET, handleRequest as POST, handleRequest as OPTIONS }