This project demonstrates a basic authentication system using React Router v7, showcasing its new features and file-based routing system.
- File-based routing with React Router v7
- Authentication flow (login, logout, protected routes)
- Session management using cookies
- TypeScript support
- Tailwind CSS for styling
app/routes
: Contains route components (home, login, logout)app/services
: Includes session management logicapp/root.tsx
: Root component and layout definitionapp/routes.ts
: Route configuration using React Router v7 syntax
Run the dev server:
npm run dev
First, build your app for production:
npm run build
Then run the app in production mode:
npm start
If you're familiar with deploying Node applications, the built-in app server is production-ready.
Make sure to deploy the output of npm run build
:
build/server
build/client
- The home page (
/
) is protected and requires authentication - Users can log in at
/login
- Logout is handled at
/logout
app/routes/home.tsx
: Protected home pageapp/routes/login.tsx
: Login form and authentication logicapp/routes/logout.tsx
: Logout handlingapp/services/session.server.ts
: Session management utilities
This template comes with Tailwind CSS already configured for a simple default starting experience. You can customize the configuration in tailwind.config.ts
.