Vite Plugin
Snapshot exposes Vite helpers from @lastshotlabs/snapshot/vite.
snapshotSync
Section titled “snapshotSync”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:
snapshot sync --api http://localhost:3000 --watchsnapshotSsr
Section titled “snapshotSsr”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.
Combined Setup
Section titled “Combined Setup”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 }), ],});