Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"typescript"
],
"files": ["**", ".vscode/**", ".github/**"],
"ignorePaths": ["bun.lock", "drizzle/**"],
"ignorePaths": ["bun.lock"],
"ignoreRegExpList": ["apiKey='[a-zA-Z0-9-]{32}'"],
"import": [
"@cspell/dict-bash/cspell-ext.json",
Expand Down Expand Up @@ -43,7 +43,6 @@
"nums",
"dall",
"daveyplate",
"neondatabase",
"shadcn",
"requiredness",
"bradlc",
Expand Down
30 changes: 7 additions & 23 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
# Since .env is gitignored, you can use .env.example to build a new `.env` file when you clone the repo.
# Keep this file up-to-date when you add new variables to \`.env\`.
# Environment variables are optional for this starter.
# You can copy this file to `.env` and uncomment values if needed.

# This file will be committed to version control, so make sure not to have any secrets in it.
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.
# Public base URL of your site (optional)
# NEXT_PUBLIC_BASE_URL=http://localhost:3000

# When adding additional environment variables, the schema in "/src/env.ts"
# should be updated accordingly.

# Database URL
# The database URL is used to connect to your database. It's used for commenting, and authentication.
DATABASE_URL="postgresql://postgres:<YOUR_PASSWORD>@localhost:5432/starter"

# Authentication
# You can generate the secret via 'openssl rand -base64 32' on Unix
# @see https://www.better-auth.com/docs/installation
BETTER_AUTH_SECRET=""

# CORS allowed origins for auth endpoints
# Accepts a comma-separated list OR a JSON array of URLs
CORS_ORIGIN="http://localhost:3000"

# Production URL
# Used for authentication and metadata generation
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Build-time / tooling (optional)
# ANALYZE=false
# SOURCE_MAPS=false
Comment on lines +1 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Prefer .env.local and verify unused vars.

Next.js commonly uses .env.local for local overrides. Also, confirm ANALYZE/SOURCE_MAPS are actually consumed.

-# You can copy this file to `.env` and uncomment values if needed.
+# You can copy this file to `.env.local` and uncomment values if needed.
 
 # Public base URL of your site (optional)
 # NEXT_PUBLIC_BASE_URL=http://localhost:3000
 
 # Build-time / tooling (optional)
 # ANALYZE=false
 # SOURCE_MAPS=false
+# NEXT_TELEMETRY_DISABLED=1

Run to verify usage:


🏁 Script executed:

#!/bin/bash
rg -nC2 -F "process.env.ANALYZE" || true
rg -nC2 -F "process.env.SOURCE_MAPS" || true

Length of output: 431


Prefer .env.local; ANALYZE and SOURCE_MAPS are used.

next.config.ts reads process.env.ANALYZE (line 45) and process.env.SOURCE_MAPS (line 13) — change the .env.example instruction to copy to .env.local and keep the ANALYZE/SOURCE_MAPS entries. Optionally add NEXT_TELEMETRY_DISABLED=1.

-# You can copy this file to `.env` and uncomment values if needed.
+# You can copy this file to `.env.local` and uncomment values if needed.
 
 # Public base URL of your site (optional)
 # NEXT_PUBLIC_BASE_URL=http://localhost:3000
 
 # Build-time / tooling (optional)
 # ANALYZE=false
 # SOURCE_MAPS=false
+# NEXT_TELEMETRY_DISABLED=1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Environment variables are optional for this starter.
# You can copy this file to `.env` and uncomment values if needed.
# This file will be committed to version control, so make sure not to have any secrets in it.
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.
# Public base URL of your site (optional)
# NEXT_PUBLIC_BASE_URL=http://localhost:3000
# When adding additional environment variables, the schema in "/src/env.ts"
# should be updated accordingly.
# Database URL
# The database URL is used to connect to your database. It's used for commenting, and authentication.
DATABASE_URL="postgresql://postgres:<YOUR_PASSWORD>@localhost:5432/starter"
# Authentication
# You can generate the secret via 'openssl rand -base64 32' on Unix
# @see https://www.better-auth.com/docs/installation
BETTER_AUTH_SECRET=""
# CORS allowed origins for auth endpoints
# Accepts a comma-separated list OR a JSON array of URLs
CORS_ORIGIN="http://localhost:3000"
# Production URL
# Used for authentication and metadata generation
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Build-time / tooling (optional)
# ANALYZE=false
# SOURCE_MAPS=false
# Environment variables are optional for this starter.
# You can copy this file to `.env.local` and uncomment values if needed.
# Public base URL of your site (optional)
# NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Build-time / tooling (optional)
# ANALYZE=false
# SOURCE_MAPS=false
# NEXT_TELEMETRY_DISABLED=1
🤖 Prompt for AI Agents
In .env.example around lines 1 to 9, update the usage instructions to recommend
copying to `.env.local` (not `.env`), reintroduce commented ANALYZE and
SOURCE_MAPS entries so they match next.config.ts expectations, and optionally
add a commented NEXT_TELEMETRY_DISABLED=1 line; ensure the example shows the
three variables commented out with brief labels so developers can enable ANALYZE
and SOURCE_MAPS and disable telemetry if desired.

147 changes: 26 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,34 @@
<p align="center">
<img alt="" src="/.github/assets/cover.png" />
</p>
# Next.js Starter

<h1 align="center">
Better Auth Next.js Starter
</h1>
A minimal, clean Next.js starter that preserves a polished UI foundation without authentication or a database.

<p align="center">
<a aria-label="Framework" href="https://nextjs.org">
<img alt="" src="https://img.shields.io/badge/Next.js-000000.svg?style=for-the-badge&logo=Next.js&labelColor=000">
</a>
<img alt="" src="https://img.shields.io/github/languages/top/techwithanirudh/better-auth-nextjs-starter?style=for-the-badge&labelColor=000">
<a aria-label="License" href="https://github.com/techwithanirudh/better-auth-nextjs-starter/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/github/license/techwithanirudh/better-auth-nextjs-starter?style=for-the-badge&labelColor=000">
</a>
</p>
Features
- Next.js (App Router) + TypeScript (strict)
- Tailwind CSS v4 with modern design tokens
- shadcn/ui components (Button, Card, Input, and more)
- Dark mode via next-themes
- Toasts with sonner
- Navigation progress bar with bprogress
- SEO metadata helpers and sensible security headers

## Quickstart
Pages included
- `/` — Welcome page with quick links and stack overview
- `/about` — Example static page showing metadata usage
- `/components` — Simple gallery using shadcn/ui components
- `/api/health` — Minimal API responding with `{ status: "ok" }`
Comment on lines +5 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix markdownlint issues (blank lines + bare URLs).

Add blank lines around lists and format URLs as Markdown links.

-Features
+- Features
+
 - Next.js (App Router) + TypeScript (strict)
@@
-Pages included
+- Pages included
+
 - `/` — Welcome page with quick links and stack overview
@@
-Getting started
+- Getting started
+
 This starter has zero required environment variables. Clone the repo and start building.
@@
-How to add Auth and DB later
+- How to add Auth and DB later
+
-- Auth: better-auth — https://better-auth.com/docs
-- UI: better-auth-ui — https://better-auth-ui.com
-- ORM/DB: Drizzle ORM — https://orm.drizzle.team/docs
+- Auth: better-auth — <https://better-auth.com/docs>
+- UI: better-auth-ui — <https://better-auth-ui.com>
+- ORM/DB: Drizzle ORM — <https://orm.drizzle.team/docs>
@@
-Notes
+- Notes
+
 - The project intentionally excludes auth and database code to give you a clean base. Add your preferred solutions when you need them.

Also applies to: 20-27, 28-35

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

6-6: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


15-15: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

🤖 Prompt for AI Agents
In README.md around lines 5 to 18 (and also apply to 20-27 and 28-35), the
markdown lists lack surrounding blank lines and there are bare URLs; to fix, add
a blank line before each list and after each list block, and replace any bare
URLs with proper Markdown link syntax ([text](url)) or inline link text,
ensuring list items remain unchanged; run markdownlint to verify no more
blank-line or bare-URL warnings.


1) Create a PostgreSQL database (local or hosted).
Getting started
This starter has zero required environment variables. Clone the repo and start building.

2) Copy `.env.example` in the project root and fill in the variables below.

3) Generate schema and run database migrations.

```bash
bun run auth:generate
bun run db:generate
bun run db:push
```

4) Start the dev server.

```bash
bun run dev
```


## Environment variables

All configuration is typed and validated in `src/env.ts`. Requiredness differs between development and production as described.

```bash
# Runtime (server-only)

# PostgreSQL connection string (required)
# Format must be a valid URL
DATABASE_URL="postgresql://postgres:<YOUR_PASSWORD>@localhost:5432/starter"

# Better Auth secret (required in production; optional in development)
# You can generate via: openssl rand -base64 32
# Docs: https://www.better-auth.com/docs/installation#set-environment-variables
BETTER_AUTH_SECRET=""

# CORS allowed origins for auth endpoints
# Accepts a comma-separated list OR a JSON array of URLs
# Examples:
# CORS_ORIGIN="http://localhost:3000,https://your-domain.com"
# CORS_ORIGIN='["http://localhost:3000","https://your-domain.com"]'
CORS_ORIGIN="http://localhost:3000"

# Google Gemini API key (required)
GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key_here


# Runtime (client-exposed)

# Public base URL of your site (required)
# Must be a full URL including protocol
# Example (dev): http://localhost:3000
# Example (prod): https://your-domain.com
NEXT_PUBLIC_BASE_URL=http://localhost:3000


# Build-time / tooling (optional)

# Enable bundle analyzer for production builds
ANALYZE=false

# Emit production browser source maps
SOURCE_MAPS=false
```
How to add Auth and DB later
- Auth: better-auth — https://better-auth.com/docs
- UI: better-auth-ui — https://better-auth-ui.com
- ORM/DB: Drizzle ORM — https://orm.drizzle.team/docs

Notes
- `CORS_ORIGIN` may be a single URL, a comma-separated list, or a JSON array. All values must be valid URLs.
- `BETTER_AUTH_SECRET` is mandatory in production. In development it can be left empty to use the library defaults, but setting it early avoids surprises.
- `NEXT_PUBLIC_BASE_URL` is used for authentication, metadata, and sitemap generation. It must be the publicly reachable URL of your app.


## Database and migrations

This starter uses Drizzle ORM with PostgreSQL. Common commands:

```bash
# Generate SQL from schema
bun run db:generate

# Apply migrations
bun run db:push

# Open Drizzle Studio
bun run db:studio
```


## Features

[Better Auth](https://better-auth.com)

[Better Auth UI](https://better-auth-ui.com)

[shadcn/ui](https://ui.shadcn.com)

[TailwindCSS](https://tailwindcss.com)

[Drizzle ORM](https://orm.drizzle.team)

[PostgreSQL](https://postgresql.org)

[Biome](https://biomejs.dev)

[Next.js](https://nextjs.org)

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme).
- The project intentionally excludes auth and database code to give you a clean base. Add your preferred solutions when you need them.
- Type checking, linting, and formatting are configured via TypeScript and Biome.
- Sitemap generation is included via next-sitemap.

After creating a project, set the environment variables from the section above in the Vercel project settings and redeploy.
License
MIT
12 changes: 0 additions & 12 deletions drizzle.config.ts

This file was deleted.

51 changes: 0 additions & 51 deletions drizzle/0000_powerful_ulik.sql

This file was deleted.

Loading
Loading