Vite Plugin
The @shiftapi/vite-plugin starts your Go server, proxies API requests, and regenerates TypeScript types on every save.
Installation
Section titled “Installation”npm install shiftapi @shiftapi/vite-pluginConfiguration
Section titled “Configuration”Add the plugin to your Vite config:
import { defineConfig } from "vite";import { shiftapi } from "@shiftapi/vite-plugin";
export default defineConfig({ plugins: [shiftapi()],});Then create a shiftapi.config.ts in your project root:
import { defineConfig } from "shiftapi";
export default defineConfig({ server: "./server/main.go",});Config options
Section titled “Config options”| Option | Default | Description |
|---|---|---|
server | — | Path to your Go server entry point (required) |
url | "http://localhost:8080" | Address your Go server listens on |
baseUrl | "/" | Base URL for the generated client |
What the plugin does
Section titled “What the plugin does”- Starts your Go server during development
- Proxies API requests to the Go server
- Fetches the OpenAPI spec from
/openapi.json - Generates a fully-typed TypeScript client in
.shiftapi/
import { client } from "shiftapi/client";
const { data } = await client.POST("/hello", { body: { name: "World" },});
console.log(data.message);// ^? (property) message: stringTypes are regenerated automatically when you save a Go file — changes appear in your editor via Vite’s HMR.