@grafbase/nextjs-plugin
v0.0.2
Published
A Next.js "plugin" that automatically starts the Grafbase CLI.
Readme
@grafbase/nextjs-plugin
A Next.js "plugin" that automatically starts the Grafbase CLI.
Usage
It's easy as 123!
Step 1
Install grafbase as a devDependency:
npm install -D grafbase @grafbase/nextjs-pluginStep 2
Add the following to .env:
GRAFBASE_API_URL=http://localhost:4000/graphql
# OR
# NEXT_PUBLIC_GRAFBASE_API_URL=http://localhost:4000/graphqlStep 3
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 = nextConfigFinally run your Next.js app! The Grafbase CLI will be running with your backend.
Notes
If there is no environment variable the Grafbase CLI will not start.
