Sitelet https://github.com/ngethan/hackwashu-fullstack-workshop-template
Skip to content

Repository files navigation

HackWashu Template - T3 Stack with Better Auth

This is a T3 Stack project bootstrapped with create-t3-app and migrated to use Better Auth for authentication.

Features

  • Better Auth for modern authentication with email/password
  • Todo Management - Full CRUD operations for todos
  • Next.js 15 App Router
  • tRPC for type-safe API routes
  • Drizzle ORM with PostgreSQL
  • Tailwind CSS for styling
  • TypeScript for type safety

Getting Started

Prerequisites

  • Node.js 18+ and pnpm
  • PostgreSQL database

Setup

  1. Clone the repository

  2. Copy .env.example to .env and configure:

    cp .env.example .env
  3. Update the .env file with your configuration:

    • Generate a secret: openssl rand -base64 32
    • Set BETTER_AUTH_SECRET to the generated value
    • Configure your database URL in DATABASE_URL
  4. Install dependencies:

    pnpm install
  5. Setup the database:

    pnpm db:push
    # or run migrations:
    pnpm db:migrate
  6. Start the development server:

    pnpm dev
  7. Visit http://localhost:3000

Authentication

This template uses Better Auth with the following features:

  • Email/Password Authentication: Users can sign up and log in with email and password
  • Session Management: Secure session handling with database storage
  • Protected Routes: Easy to protect pages and API routes

How to Use the App

  1. Visit /auth to access the login/signup page
  2. Create an account with email and password
  3. Once logged in, you'll be redirected to the home page
  4. Click "Go to Todos" to access your todo list
  5. Create, complete, and delete todos as needed

Adding Authentication to Your Components

Client Components

import { useSession } from "~/lib/auth-client";

export function MyComponent() {
  const { data: session } = useSession();

  if (session) {
    return <div>Welcome {session.user?.email}!</div>;
  }

  return <div>Not logged in</div>;
}

Server Components

import { getSession } from "~/server/auth";

export default async function Page() {
  const session = await getSession();

  if (!session) {
    redirect("/auth");
  }

  return <div>Protected content</div>;
}

Tech Stack

Learn More

To learn more about the T3 Stack, take a look at the following resources:

You can check out the create-t3-app GitHub repository — your feedback and contributions are welcome!

How do I deploy this?

Follow our deployment guides for Vercel, Netlify and Docker for more information.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages