ZeroStarterRC
ZeroStarter

Installation

Step-by-step guide to install and set up ZeroStarter.

Overview

This guide will walk you through installing and setting up ZeroStarter on your local machine. You'll learn how to clone the repository, install dependencies, configure environment variables, set up the database, and configure authentication.

Getting Started

Prerequisites

  • Bun (v1.3.0 or later)

Installation

  1. Clone this template:

    bunx gitpick https://github.com/nrjdalal/zerostarter/tree/main
    cd zerostarter

    Note: The main branch is the latest stable release.

  2. Install dependencies:

    bun install

    Note: If the installation fails, try using bun install --ignore-scripts

  3. Set up environment variables:

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

    NODE_ENV=local
    
    # -------------------- Server variables --------------------
    
    HONO_APP_URL=http://localhost:4000
    HONO_TRUSTED_ORIGINS=http://localhost:3000
    
    # Generate using `openssl rand -base64 32`
    BETTER_AUTH_SECRET=
    
    # Generate at `https://github.com/settings/developers`
    GITHUB_CLIENT_ID=
    GITHUB_CLIENT_SECRET=
    
    # Generate at `https://console.cloud.google.com/apis/credentials`
    GOOGLE_CLIENT_ID=
    GOOGLE_CLIENT_SECRET=
    
    # Generate using `bunx pglaunch -k`
    POSTGRES_URL=
    
    # -------------------- Client variables --------------------
    
    NEXT_PUBLIC_APP_URL=http://localhost:3000
    NEXT_PUBLIC_API_URL=http://localhost:4000
    
    # Optional: Manage user feedback `https://zerostarter.dev/docs/manage/feedback`
    NEXT_PUBLIC_USERJOT_URL=

Database Setup

  1. Ensure your PostgreSQL server is running.

  2. Run the generation:

    bun run db:generate
  3. Run the migration:

    bun run db:migrate

Authentication Setup

ZeroStarter comes with some default authentication plugins using Better Auth, you can extend as needed.

GitHub

  1. Create a GitHub OAuth App at GitHub Developer Settings.
  2. Set the Homepage URL to http://localhost:3000.
  3. Set the Authorization callback URL to http://localhost:3000/api/auth/callback/github.
  4. Copy the Client ID and Client Secret into your .env file.

Google

  1. Create a Google OAuth App in the Google Cloud Console.
  2. Configure the OAuth consent screen (External).
  3. Create an OAuth Client ID (Application type: Web).
  4. Set the Authorized JavaScript origins to http://localhost:3000.
  5. Set the Authorized redirect URI to http://localhost:4000/api/auth/callback/google.
  6. Copy the Client ID and Client Secret into your .env file.

Running the Application

bun dev

Running the Application with Docker Compose

docker compose up

Accessing the Application