Quickstart
This walks through the whole loop: a scaffolded app, a generated resource with a working REST API and admin UI, and a live deploy to Cloudflare Workers — no hand-written boilerplate at any step.
1. Scaffold the app
Section titled “1. Scaffold the app”npx @flare/cli create myappcd myappflare create writes a vinext app with TypeScript and Tailwind already
configured, and wires up:
- D1 + Drizzle — a
DBbinding with nodatabase_id, so Wrangler auto-provisions the database on first deploy and simulates it locally.db/schema.tsis the single Drizzle schema entry point. - Better Auth — email/password sign-up and sign-in, session cookies,
and a Drizzle adapter over the same database. Add
--auth-providers google,githubto also scaffold OAuth buttons (they only render once you set the matching client ID/secret). - R2 — a
STORAGEbinding andlib/storage.tswith signed upload/read URL helpers. - Resend —
lib/mail.ts, with a transactional email template. Without aRESEND_API_KEY, emails print to the console instead of failing.
It installs dependencies and runs wrangler types for you, so
env.DB/env.STORAGE/etc. are typed immediately.
2. Generate a resource
Section titled “2. Generate a resource”npx flare gen resource Contact --fields "name:string, email:string!, status:enum(lead,customer)"One command, one resource descriptor, and Flare emits everything that descriptor implies:
- a Drizzle table and a D1 migration
- Zod validators (strict — no mass assignment)
- a REST API (
GET/POSTon/api/contacts,GET/PATCH/PUT/DELETEon/api/contacts/[id]) - a typed fetch client (
resources/contact.client.ts) - admin pages: list, create, and edit — wired to
<ResourceTable>and<ResourceForm>, with no hand-written UI
See what gen resource emits for the full
file list.
3. Apply the migration and run it
Section titled “3. Apply the migration and run it”npx flare migratenpx flare devOpen /admin and sign up — the first account can see the new Contacts
resource in the sidebar immediately, with a working list, create, and edit
flow, form validation, and empty/error states, all generated.
4. Deploy
Section titled “4. Deploy”npx flare deployThis wraps vinext-cloudflare deploy:
- Applies remote D1 migrations before the new code goes live (a failed migration aborts the deploy; a first deploy lets Wrangler provision the database, then migrates it).
- Builds and deploys the Worker.
- Generates and uploads
BETTER_AUTH_SECRETif it isn’t set remotely yet (never reusing your local dev secret), and lists any other optional secrets (OAuth credentials,RESEND_API_KEY) you haven’t set.
You’ll need wrangler login once, the first time you deploy anything.
5. Make yourself an admin
Section titled “5. Make yourself an admin”Sign-up creates a user with no elevated role. Grant yourself admin:
npx flare user:role you@example.com admin --remoteReload /admin — you now see every action the admin role allows. See
roles & policies to restrict what other
roles can do.
What you just got
Section titled “What you just got”A live URL, backed by D1, with:
- email/password auth end-to-end
- a
Contactresource with a real REST API and validation - an admin dashboard styled per Flare’s style guide — monochrome, accessible, dark-mode-ready
- a KV-backed data cache invalidated automatically on every write
No file in this loop was hand-written. Edit the descriptor and re-run gen resource any time — see the
codegen overwrite contract for exactly what
survives a re-run.