8000 GitHub - lucasamonrc/auth101: A sample react-router application to explain authentication
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

lucasamonrc/auth101

Repository files navigation

🔐 Auth101: React Router Authentication with remix-auth

React Router Remix Auth TypeScript React

A sample repository demonstrating how to implement authentication in React Router applications using remix-auth. This project showcases multiple authentication strategies including GitHub OAuth and Trinsic authentication.

✨ Features

  • 🔒 Multiple authentication strategies (GitHub, Trinsic)
  • 🛡️ Protected routes with authentication guards
  • 🔄 Session management with cookies
  • 🧩 TypeScript for type safety
  • 🎨 Clean UI with Tailwind CSS
  • 📱 Responsive design

🚀 Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn

Installation

  1. Clone the repository:

    git clone https://github.com/lucasamonrc/auth101.git
    cd auth101
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory with the following variables:

    GITHUB_CLIENT_ID=your_github_client_id
    GITHUB_CLIENT_SECRET=your_github_client_secret
    TRINSIC_ACCESS_TOKEN=your_trinsic_access_token
    
  4. Start the development server:

    npm run dev
  5. Open your browser and navigate to http://localhost:5173

🔍 How It Works

Authentication Flow

  1. User navigates to the login page
  2. User selects an authentication provider (GitHub or Trinsic)
  3. User is redirected to the provider's authentication page
  4. After successful authentication, the provider redirects back to our callback URL
  5. The application creates a session for the authenticated user
  6. User is redirected to the protected home page

Project Structure

app/
├── models/          # Data models
├── routes/          # Application routes
│   ├── auth/        # Authentication routes
│   │   ├── github/  # GitHub authentication
│   │   └── trinsic/ # Trinsic authentication
│   ├── home.tsx     # Protected home page
│   └── login.tsx    # Login page
├── services/        # Services
│   └── authenticator.ts  # Authentication service
└── sessions.server.ts    # Session management

🛠️ Technologies Used

  • React Router v7: For routing and navigation
  • remix-auth: Authentication library for React applications
  • TypeScript: For type safety
  • Tailwind CSS: For styling
  • Vite: For fast development and building

📚 Learn More

🙏 Acknowledgements

About

A sample react-router application to explain authentication

Topics

Resources

Stars

Watchers

Forks

0