Skip to content

Latest commit

 

History

History

examples

README.md

Lunora examples

Runnable apps, each one built around a different part of the framework. Every one deploys to your own Cloudflare account in a click — the button clones the repo, provisions the bindings its wrangler.jsonc declares, prompts for any secret listed in .dev.vars.example, and deploys.

Example What it is Shows off Deploy
kanban-board Drag-and-drop board, live for everyone looking at it Fractional index ordering, server-resolved drops, multi-query optimistic updates Deploy
feedback-board Public feature-request board with AI summaries Unique index as a constraint, denormalised counters, ctx.ai from an action Deploy
team-chat Channels, presence, search, file uploads A shard per channel, all three data tiers, authorizeShard, signed R2 uploads Deploy
chess Multiplayer chess with lobbies, spectators and Elo Server-authoritative rules, serialized mutations as a game rule, in-transaction settlement Deploy
tanstack-start SSR that hands over to a live socket Route loaders sharing a cache key with useQuery, one worker for SSR + RPC Deploy
todo-app The smallest CRUD round-trip defineSchema, one query + one mutation, optimistic updates —
blog Posts, drafts, semantic search .vectorize() semantic search, signed R2 uploads, code-first crons —
realtime-cursors Shared cursors, one shard per room .shardBy() and per-room WebSocket fan-out —
auth-playground Sign-in, organizations, admin, 2FA @lunora/auth with the better-auth plugin surface —
clerk-auth Clerk as the identity provider @lunora/jwt-auth clerk(), RLS on the Clerk user id, an org-admin query, token on live sockets —
workos-auth WorkOS AuthKit as the identity provider @lunora/jwt-auth workos(), RLS on the WorkOS user id, a role-gated query, token on live sockets —
payment-demo Checkout and subscription state @lunora/payment, webhook sync, entitlements —
notify-demo Web Push notifications @lunora/notify, subscription stores, ctx.push.broadcast device fan-out —
offline-rejections What an offline queue does when the server says no Durable offline outbox, rejection replay —
expo React Native client @lunora/react-native, the Expo auth bridge —
privacy Data-subject requests: export, erasure, cancel @lunora/privacy, durable workflows, per-call ports —

Which examples are safe to deploy

team-chat and chess require a sign-in. The other three deliberately have no auth — they exist to demonstrate one mechanism each — so a deployed instance is open to anyone with the URL. Each says so above its own deploy button.

Composing the worker: two shapes

team-chat and chess build their worker with the generated defineApp() builder; kanban-board, feedback-board and the older blog / auth-playground call createWorker + createShardDO directly.

Prefer defineApp(). It wires both halves of a capability together — the ctx.* surface inside the shard and the matching admin/studio surface on the worker — so the two cannot disagree. The hand-rolled form is worth reading once to see what the builder does, and it is the right choice when you need a capability the builder does not model, but it is easy to get subtly wrong: omitting .global()'s D1 binding, for instance, compiles cleanly and then throws "no global backend configured" on the first read of a .global() table. The examples with no bindings at all (kanban-board, feedback-board) stay on the direct form precisely because there is nothing to wire.

Running any of them locally

pnpm install
pnpm --filter @lunora-example/<name> dev

Then open the URL the dev server prints (http://localhost:5173 in the main checkout). Examples that need a D1 database, an R2 bucket, or a secret say so in their own README — everything else runs offline in Miniflare.

A note on the deploy buttons

Cloudflare's deploy flow builds the example from its subdirectory in this monorepo. If a build fails on dependency resolution, deploy from a checkout instead — it is two commands and does the same thing:

pnpm install
pnpm --filter @lunora-example/<name> run deploy