Skip to content
LogoLogo

How to build from a snapshot

This guide shows you how to build your application from a committed copy of your project data. Your build then makes no request to the Picked API. A change in the dashboard gets to your users only after you write a new copy and deploy. Your project must have the Vite plugin and the CLI.

1. Write the snapshot

Run this command in the directory of picked.config.ts:

npx picked pull

The command writes picked.snapshot.json. The file holds the workspace schema, the project options and the CMS content of each experience.

If you chose a draft workspace with picked workspace use, the command stops. Choose the published version, or add --allow-preview to write content that is not published.

2. Set the data mode

Set data to 'snapshot' in picked.config.ts:

picked.config.ts
import { defineConfig } from 'picked/config'
 
export default defineConfig({
  projectId: 'your-project-id',
  data: 'snapshot',
})

vite dev and vite build now read the snapshot. Type generation reads its schema.

3. Commit the snapshot

Commit picked.snapshot.json with picked.config.ts. The file holds no preview token.

A build stops when there is no file. The message tells you to run picked pull.

4. Write a new snapshot

To send a dashboard change to your users, run npx picked pull again. Then commit and deploy.

If two branches change the file, do not edit it by hand. Keep one version, then run npx picked pull again.

5. Find an old snapshot in CI

Add this step to your CI to fail when the published version is newer than the file:

npx picked pull --check
  • data — every data mode of the Vite plugin.
  • picked pull — the command and its options.