Public
Like
untitled-9454
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.
main.tsx
https://Varun07--35aaf0763bcc11f0b0d59e149126039e.web.val.run
A complete authentication system with login and registration functionality built with React and Hono.
- 🔐 User authentication (login/logout)
- 📝 User registration
- 🍪 Session management with cookies
- 💾 SQLite database for user storage
- 🎨 Beautiful UI with TailwindCSS
- 📱 Responsive design
- ⚡ Real-time form validation
- Username: demo
- Password: demo123
├── backend/
│ └── index.ts # Hono API server with auth endpoints
├── frontend/
│ ├── index.html # Main HTML template
│ ├── index.tsx # React app entry point
│ └── components/
│ ├── App.tsx # Main app component
│ ├── LoginForm.tsx # Login/registration form
│ └── Dashboard.tsx # Protected dashboard
├── main.tsx # HTTP trigger entry point
└── README.md
POST /api/login
- Authenticate userPOST /api/register
- Create new user accountPOST /api/logout
- End user sessionGET /api/auth
- Check authentication status
The app uses SQLite with a simple users table:
CREATE TABLE login_users_1 ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE NOT NULL, password TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP );
- HTTP-only cookies for session management
- Secure cookie settings
- Input validation
- SQL injection protection with parameterized queries
- Password length requirements
- Visit the login page
- Use demo credentials or create a new account
- Access the protected dashboard after authentication
- Sign out to return to the login page
- Frontend: React 18, TailwindCSS
- Backend: Hono, SQLite
- Platform: Val Town
- Authentication: Cookie-based sessions