Monorepo
Monorepo and subdomains
The project is a pnpm workspace with three deployable surfaces:
Shared UI and libraries live in packages/shared, packages/core (config + small shared types), and packages/server (database, Better Auth, billing, webhooks).
Environment
BETTER_AUTH_URL: origin of the app deployment (where/api/authis served).BETTER_AUTH_TRUSTED_ORIGINS: include both marketing and app origins in production.BETTER_AUTH_COOKIE_DOMAIN: optional, e.g..yournextsaas.xyz, so the session cookie is visible on both apex andapp(for marketing loaders that callgetSession()).VITE_SITE_URL: canonical base for each app (marketing vs app may differ).VITE_APP_ORIGIN/VITE_MARKETING_ORIGIN: used byappHref()/marketingHref()in shared code for cross-app links when origins differ.
Local development
- Marketing:
pnpm dev:marketing(default port 3000). - Docs:
pnpm dev:docs(default port 3002); root URLs like/guide/monorepo(no/docsprefix).
For Sign in / Dashboard links on the landing page to reach the product app, set VITE_APP_ORIGIN=http://localhost:3001. For Better Auth not to reject requests with Invalid origin, set BETTER_AUTH_TRUSTED_ORIGINS to include both http://localhost:3000 and http://localhost:3001. For links from marketing to the docs app, set VITE_DOCS_ORIGIN=http://localhost:3002 (or your production docs URL). Details: Environment variables.
Related
- Project rules — conventions and stack.
- Environment variables — full
.envreference.