Public
Like
7
luciaMagicLinkStarter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v82View latest version
A demonstration of magic link authentication using Val Town.
- Magic link authentication
- Server-side rendering with client-side hydration
- User profile management (username editing)
- Session management with secure cookies
- Responsive UI with Tailwind CSS
- User enters their email address on the login page
- A magic link is sent to the user's email
- User clicks the magic link in their email
- The server validates the token, creates a session, and sets a secure cookie
- User is redirected to the authenticated home page
- Database: SQLite for storing users, sessions, and magic link tokens
- Frontend: React with Tailwind CSS
- Backend: Hono.js for API routes and middleware
- Authentication: Custom implementation with secure cookies
POST /auth/magic-link
- Request a magic linkGET /auth/magic-link/:token
- Validate a magic link tokenPOST /auth/logout
- Log out the current userPOST /api/user/username
- Update the user's username
- Email sending requires Val Town Pro subscription for sending to addresses other than your own
- Magic links expire after 15 minutes
- Sessions expire after 30 days