A Next.js "plugin" that automatically starts the Grafbase CLI.
It's easy as 123!
Install grafbase
as a devDependency
:
npm install -D grafbase @grafbase/nextjs-plugin
Add the following to .env
:
GRAFBASE_API_URL=http://localhost:4000/graphql
# OR
# NEXT_PUBLIC_GRAFBASE_API_URL=http://localhost:4000/graphql
Then inside next.config.js
import withGrafbase
, and wrap your exported config:
/** @type {import('next').NextConfig} */
const { withGrafbase } = require('@grafbase/nextjs-plugin')
const nextConfig = () =>
withGrafbase({
reactStrictMode: true,
swcMinify: true
})
module.exports = nextConfig
Finally run your Next.js app! The Grafbase CLI will be running with your backend.
If there is no environment variable the Grafbase CLI will not start.