---
description:
  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 an API Route.
---

import { Callout } from '@theguild/components'

# Integration with Next.js

[Next.js](https://nextjs.org) 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](https://nextjs.org/docs/app/building-your-application/routing/router-handlers).

## Example

```ts
// 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 }
```
