Deployment
This guide covers how Sustentus applications are deployed. Each app in the monorepo deploys independently to Vercel as its own project, with its own environment variables and custom domain. Shared packages are built and bundled with the apps that consume them — they are not deployed separately.
For the full pipeline from commit to production (pre-commit, CI, and Vercel preview/production builds), see CI/CD pipeline.
Per-app Vercel configuration
Each app is a separate Vercel project. Set the root directory and build command, then add the app’s environment variables in the project settings.
| App | Root directory | Build command | Output directory |
|---|---|---|---|
| Marketing | apps/marketing | cd ../.. && pnpm marketing:build | .next |
| Docs | apps/docs | cd ../.. && pnpm docs:build | .next |
| Storybook | apps/storybook | cd ../.. && pnpm storybook:build | storybook-static |
Install command is pnpm install for all projects.
Continuous deployment
Vercel deploys automatically: pushing to a PR branch publishes a preview build, and merging to main promotes to production. To roll back, open Deployments, find a previous deployment, and click Promote to Production.
Custom domains
In Project Settings > Domains, add the domain and configure DNS; the SSL certificate is provisioned automatically.
Environment variables
Manage variables in the Vercel dashboard or via the CLI:
vercel env add CLERK_SECRET_KEY production
vercel env pull .env.localVariables by app
Marketing:
# Required
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...
# Optional
NEXT_PUBLIC_POSTHOG_KEY=phc_...
NEXT_PUBLIC_POSTHOG_HOST=https://...Documentation and Storybook: none required (static documentation / component showcase).
Scheduled jobs (cron)
The web app runs scheduled work through Vercel cron jobs , declared in apps/web/vercel.json. Crons run only against the production deployment.
| Schedule | Path | Job |
|---|---|---|
0 2 * * * | /api/cron/csm-portfolio-snapshot | Writes the daily per-CSM portfolio snapshot so the go live trend is a real day-over-day delta. |
Cron routes are protected by a shared secret. Set CRON_SECRET for the web app; Vercel sends it as Authorization: Bearer <CRON_SECRET> on each cron request, and the route rejects anything else with 401, so it is unreachable from a normal user session.
vercel env add CRON_SECRET productionBuild verification
Test a production build locally before deploying:
pnpm marketing:build
cd apps/marketing
pnpm start
# Visit http://localhost:3001Static export (docs)
The documentation site can be exported as a static site by setting output: "export" in apps/docs/next.config.ts; pnpm docs:build then emits to apps/docs/out/ for upload to any static host.
Storybook hosting
pnpm storybook:build outputs to apps/storybook/storybook-static/, which can be deployed to any static host. Chromatic additionally provides Storybook hosting, visual testing, and component review:
pnpm add -D chromatic --filter=@sustentus/storybook
npx chromatic --project-token=<token>