Skip to content

Vite Plugin

Snapshot exposes Vite helpers from @lastshotlabs/snapshot/vite.

Run OpenAPI sync during Vite startup/build:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { snapshotSync } from "@lastshotlabs/snapshot/vite";
export default defineConfig({
plugins: [
react(),
snapshotSync({ file: "./schema.json", zod: true }),
],
});

Use the CLI for live API polling:

Terminal window
snapshot sync --api http://localhost:3000 --watch

Add Snapshot SSR build helpers:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { snapshotSsr } from "@lastshotlabs/snapshot/vite";
export default defineConfig({
plugins: [
react(),
...snapshotSsr({
rsc: true,
ppr: true,
}),
],
});

snapshotSsr() configures client/server build output and can generate route prefetch metadata, static route metadata, RSC metadata, and PPR route metadata.

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { snapshotSync, snapshotSsr } from "@lastshotlabs/snapshot/vite";
export default defineConfig({
plugins: [
react(),
snapshotSync({ file: "./schema.json" }),
...snapshotSsr({ rsc: true }),
],
});