A sample website with a complete, working email + password authentication system built on Val Town.
Create an account (or log in with the test user sam@example.com / supersecret1), and you'll land on a members-only dashboard.
| Capability | Implementation |
|---|---|
| Server | Hono + JSX (index.tsx) |
| Users & sessions | SQLite, scoped to this val (lib/db.ts) |
| Password hashing | PBKDF2 (100k iterations, per-user 16-byte salt) via WebCrypto (lib/security.ts) |
| Sessions | Random 256-bit token stored in the DB, delivered as an HttpOnly, Secure, SameSite=Lax cookie signed with HMAC-SHA256 |
| Route protection | /dashboard requires a valid session; otherwise redirects to /login |
GET / — homepageGET/POST /signup — create an account (auto-logs you in)GET/POST /login — sign inPOST /logout — destroy the sessionGET /dashboard — protected page for authenticated usersSESSION_SECRET, and sessions can be revoked server-side on logout.SESSION_SECRET — secret used to sign session cookies. Set it to a long random string before going to production. It's already configured on this val.index.tsx — HTTP entrypoint (routes + views)lib/security.ts — password hashing and cookie signinglib/db.ts — SQLite schema and queries