Skip to Content

Integration with Next.js

Next.js is a web framework that allows you to build websites very quickly and Hive Gateway 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 { createGatewayRuntime } from '@graphql-hive/gateway-runtime' const { handleRequest } = createGatewayRuntime({ /* Your configuration here before the following required settings */ // While using Next.js file convention for routing, we need to configure Hive Gateway to use the correct endpoint graphqlEndpoint: '/api/graphql', // Hive Gateway 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 }
Last updated on