Skip to content

Next.js Plugin

The @shiftapi/next plugin integrates ShiftAPI with Next.js, providing the same automatic type generation during development.

Terminal window
npm install shiftapi @shiftapi/next

Wrap your Next.js config with withShiftAPI:

next.config.ts
import { withShiftAPI } from "@shiftapi/next";
export default withShiftAPI({
// your Next.js config here
});

Then create a shiftapi.config.ts in your project root:

shiftapi.config.ts
import { defineConfig } from "shiftapi";
export default defineConfig({
server: "./server/main.go",
});
OptionDefaultDescription
serverPath to your Go server entry point (required)
url"http://localhost:8080"Address your Go server listens on
baseUrl"/"Base URL for the generated client
import { client } from "shiftapi/client";
const { data } = await client.POST("/hello", {
body: { name: "World" },
});
console.log(data.message);
// ^? (property) message: string

The plugin handles starting your Go server, proxying requests, and regenerating types — just like the Vite plugin.