Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 926 Bytes

File metadata and controls

49 lines (31 loc) · 926 Bytes

@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-plugin

Step 2

Add the following to .env:

GRAFBASE_API_URL=http://localhost:4000/graphql
# OR
# NEXT_PUBLIC_GRAFBASE_API_URL=http://localhost:4000/graphql

Step 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 = nextConfig

Finally 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.