A minimal authentication demo showcasing three different route protection patterns using Deno Fresh, Better Auth, Drizzle ORM, and Daisy UI.
This demo illustrates three authentication approaches:
- Server-side:
/dashboard- Auth check in route handler - Middleware:
/dashboard-middleware- Protected by Fresh middleware - Unprotected:
/dashboard-unprotected- No auth, unprotected
- Deno Fresh - Full-stack web framework
- Better Auth - Modern authentication
- Drizzle ORM - TypeScript-first database ORM
- SQLite - For the auth database demo
- Daisy UI - Tailwind CSS component library
- Deno: Install Deno
- SQLite: (Optional) - only for inspecting the created
auth.db
-
Setup:
deno task setup # Setup database (run once) deno task start # Start the server
-
Visit: http://localhost:8000
-
Test the demo: Create account → Try each dashboard route to see the auth differences -> Test with and without being logged in
| Login Page | Signup Page |
|---|---|
![]() |
![]() |
| Clean login form with demo routes sidebar | Account creation with form validation |
Authentication verified in route handler on each request
Protected by Fresh middleware with automatic redirects
After creating users, you can explore the SQLite auth database:
# Open SQLite CLI
sqlite3 db/auth.db
# View all tables
.tables
# See user accounts
SELECT id, name, email, emailVerified, datetime(createdAt, 'unixepoch') as created FROM user;
# See active sessions
SELECT id, datetime(expiresAt, 'unixepoch') as expires, userId FROM session;
# Exit SQLite
.exit| Route | Protection | Description |
|---|---|---|
/dashboard |
Server-side | Auth check in route handler, session verified per request |
/dashboard-middleware |
Middleware | Fresh middleware protection, automatic redirects |
/dashboard-unprotected |
None | Unprotected example showing what happens if not checking session |
Key commands:
deno task setup # Setup database tables (run once)
deno task start # Start dev serverProject structure:
├── routes/ # 3 dashboard routes showing different auth patterns
├── components/ # Dashboard UI component
├── islands/ # Login form + logout button
├── lib/auth/ # Better Auth configuration
├── db/ # Drizzle schema (user, session, account, verification)
└── tests/ # Integration tests
The database (db/auth.db) is created automatically on first run.


