Skip to content

chndrwali/nextjs-starter-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Next.js Starter Kit T3 Stack + shadcn/ui

A production-ready, full-stack Next.js 16 boilerplate with authentication, admin dashboard, database, file uploads, and type-safe APIs β€” all pre-configured so you can skip the setup and start building.

License Stars Forks

πŸ“‹ PRD Prompt Template β€’ πŸ“„ PRD Example

Tech Stack β€’ Features β€’ Getting Started β€’ Project Structure β€’ tRPC Usage β€’ Customization β€’ Deployment β€’ Special Thanks β€’ PRD Generator β€’ License


Tech Stack

Category Technology Version
Framework Next.js 16
Language TypeScript 5
UI Runtime React + React Compiler 19
Styling Tailwind CSS 4
UI Components shadcn/ui (New York) Latest
Authentication Better Auth 1.x
Database ORM Prisma 7
Database PostgreSQL (Neon recommended) β€”
API Layer tRPC 11
Data Fetching TanStack React Query 5
File Uploads UploadThing 7
Form Handling React Hook Form + Zod Latest
Charts Recharts 2
Animations GSAP 3
Email Resend (pre-configured, commented) β€”
Icons Lucide React Latest
Fonts Geist Sans & Geist Mono β€”

Features

πŸ” Authentication (Better Auth)

  • Email & Password authentication with configurable password policy
  • Admin plugin β€” role-based access control out of the box
  • Rate limiting β€” brute-force and spam protection on auth endpoints
  • Secure cookies β€” httpOnly, sameSite, secure in production
  • Session management β€” cookie caching, configurable expiry
  • Password reset flow (Resend email template included, commented out)
  • Forgot password flow with email-based reset link
  • Pre-built client exports: signIn, signUp, signOut, useSession, changePassword, resetPassword, admin

πŸ—„οΈ Database (Prisma + PostgreSQL)

  • Prisma 7 with the new PrismaPg driver adapter for connection pooling
  • Pre-defined schema: User, Account, Credential, Session, Verification
  • Admin fields: role, banned, banReason, banExpires
  • Generated client output to app/generated/prisma (git-ignored)
  • Migration-ready setup

⚑ Type-Safe API (tRPC v11)

  • baseProcedure β€” public endpoints
  • protectedProcedure β€” requires authentication (auto-injects user session)
  • adminProcedure β€” requires admin role
  • Server-side prefetching with HydrationBoundary for zero-waterfall SSR
  • SuperJSON transformer for Date, Map, Set serialization
  • Configured TRPCReactProvider with singleton query client

πŸ“ File Uploads (UploadThing)

  • 4 pre-configured file routes:
    • productImage β€” single image (4MB, auth required)
    • productImages β€” multiple images up to 5 (4MB each, auth required)
    • pdfUploader β€” single PDF (4MB, auth required)
    • publicImage β€” single image (4MB, no auth)
  • Ready-to-use components: UploadButton, UploadDropzone, useUploadThing

🎨 UI & UX

  • 56 shadcn/ui components pre-installed (New York style)
  • 12 custom components β€” password input, image/file upload, toast, alert dialog, theme toggle, user avatar, responsive modal, page container, icons, heading, login account info
  • Tailwind CSS v4 with CSS variables and tw-animate-css
  • React Compiler enabled for automatic memoization
  • next-themes for dark/light mode support (dark by default)
  • Sonner for toast notifications
  • Embla Carousel for carousels
  • Vaul for drawer components
  • Recharts for data visualization
  • react-resizable-panels for resizable layouts
  • react-day-picker for date pickers
  • cmdk for command palette
  • input-otp for OTP inputs
  • CVA + clsx + tailwind-merge for class utilities
  • GSAP animated 404 page with glitch effect, floating particles, and scanline animation

πŸ“± Admin Dashboard

  • Collapsible sidebar navigation with icon-based and expanded modes
  • RBAC-based navigation filtering β€” show/hide items based on role, permission, plan, feature, or requireOrg
  • Breadcrumbs with auto-generated items based on the current route
  • Search (Cmd+K) command palette for quick navigation
  • Notification dropdown component
  • Sign-out button with confirmation dialog
  • User avatar profile with role badge
  • Pre-configured nav items: Dashboard, Inbox, Workspaces (Portfolio, Resume), Tracker

πŸ› οΈ Custom Hooks

  • useCurrentUser() β€” reactive current user state (client)
  • getSession() β€” server-side session retrieval
  • useFilteredNavItems() β€” RBAC-based navigation filtering (client-side, no server calls)
  • useBreadcrumbs() β€” dynamic breadcrumb generation from URL segments
  • useDebounce() β€” debounce values
  • useMobile() β€” responsive breakpoint detection

πŸ”’ Auth Pages

  • Login β€” email/password with "Remember me" and "Forgot password" link, includes demo account info
  • Register β€” email/password/name with password strength indicator and rules
  • Forgot Password β€” email-based reset link request
  • Reset Password β€” set new password from email link
  • Beautiful auth layout with animated gradient background

Getting Started

Prerequisites

  • Node.js β‰₯ 20
  • npm, pnpm, or yarn
  • A PostgreSQL database (we recommend Neon β€” free tier available)
  • An UploadThing account (for file uploads)

1. Clone & Install

git clone https://github.com/chndrwali/nextjs-starter-kit.git
cd nextjs-starter-kit
npm install

2. Set Up Prisma

Initialize Prisma client and run migrations:

npx prisma init --db --output ../app/generated/prisma
npx prisma generate
npx prisma migrate dev

3. Generate Better Auth Secret

npx @better-auth/cli@latest secret

Copy the generated secret into your .env file.

4. Configure Environment Variables

Copy the example env file and fill in your values:

cp .env.example .env
# Auth Secret (generated in step 3)
BETTER_AUTH_SECRET=your_generated_secret_here
BETTER_AUTH_URL=http://localhost:3000

# Resend (for emails β€” optional)
RESEND_API_KEY=re_xxxxxxxxxxxxx

# Public URL
NEXT_PUBLIC_URL=http://localhost:3000

# Database (get this from https://neon.com/)
DATABASE_URL="postgresql://user:password@ep-xxxx.region.aws.neon.tech/dbname?sslmode=require"

# UploadThing (get this from https://uploadthing.com/)
UPLOADTHING_TOKEN='your_uploadthing_token'

Where to get each value:

Variable Source
BETTER_AUTH_SECRET Run npx @better-auth/cli@latest secret
DATABASE_URL Create a free database at neon.com β†’ copy the connection string
UPLOADTHING_TOKEN Sign up at uploadthing.com β†’ create an app β†’ copy the token
RESEND_API_KEY Sign up at resend.com β†’ API Keys β†’ create key (optional)

5. Run Development Server

npm run dev

Open http://localhost:3000 to see your app.


Project Structure

.
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (admin)/              # Admin dashboard route group
β”‚   β”‚   β”œβ”€β”€ admin/            # Admin pages (dashboard, inbox, etc.)
β”‚   β”‚   └── layout.tsx        # Admin layout with session guard
β”‚   β”œβ”€β”€ (auth)/               # Auth route group
β”‚   β”‚   β”œβ”€β”€ login/            # Login page with demo account info
β”‚   β”‚   β”œβ”€β”€ register/         # Registration page
β”‚   β”‚   β”œβ”€β”€ forgot-password/  # Forgot password page
β”‚   β”‚   β”œβ”€β”€ reset-password/   # Reset password page
β”‚   β”‚   └── layout.tsx        # Auth layout with redirect if logged in
β”‚   β”œβ”€β”€ (public)/             # Public route group
β”‚   β”‚   └── page.tsx          # Home page (redirects to /login)
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/[...all]/    # Better Auth catch-all handler
β”‚   β”‚   β”œβ”€β”€ trpc/[trpc]/      # tRPC API handler
β”‚   β”‚   └── uploadthing/      # UploadThing route handler + file router
β”‚   β”œβ”€β”€ generated/prisma/     # Prisma generated client (git-ignored)
β”‚   β”œβ”€β”€ globals.css           # Tailwind CSS + design tokens
β”‚   β”œβ”€β”€ layout.tsx            # Root layout (Geist fonts, providers)
β”‚   └── not-found.tsx         # Animated 404 page (GSAP)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ custom/               # 12 custom reusable components
β”‚   β”‚   β”œβ”€β”€ alert-dialog-custom.tsx
β”‚   β”‚   β”œβ”€β”€ app-toast.tsx
β”‚   β”‚   β”œβ”€β”€ file-upload.tsx
β”‚   β”‚   β”œβ”€β”€ heading.tsx
β”‚   β”‚   β”œβ”€β”€ icons.tsx
β”‚   β”‚   β”œβ”€β”€ image-upload.tsx
β”‚   β”‚   β”œβ”€β”€ login-account-info.tsx
β”‚   β”‚   β”œβ”€β”€ page-container.tsx
β”‚   β”‚   β”œβ”€β”€ password-input.tsx
β”‚   β”‚   β”œβ”€β”€ responsive-modal.tsx
β”‚   β”‚   β”œβ”€β”€ theme-mode-toggle.tsx
β”‚   β”‚   └── user-avatar-profile.tsx
β”‚   β”œβ”€β”€ ui/                   # 56 shadcn/ui components
β”‚   β”œβ”€β”€ theme-provider.tsx    # next-themes provider
β”‚   └── uploadthing.ts        # UploadThing component exports
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ get-session.ts        # Server-side session helper
β”‚   β”œβ”€β”€ use-breadcrumbs.ts    # Dynamic breadcrumb hook
β”‚   β”œβ”€β”€ use-current-user.ts   # Client-side current user hook
β”‚   β”œβ”€β”€ use-debounce.ts       # Debounce hook
β”‚   β”œβ”€β”€ use-mobile.ts         # Mobile breakpoint hook
β”‚   └── use-nav.ts            # RBAC-based nav filtering hook
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ auth.ts               # Better Auth server config
β”‚   β”œβ”€β”€ auth-client.ts        # Better Auth client exports
β”‚   β”œβ”€β”€ config-env.ts         # Centralized env config
β”‚   β”œβ”€β”€ form-schema.ts        # Zod schemas (login, register, etc.)
β”‚   β”œβ”€β”€ prisma.ts             # Prisma client singleton
β”‚   └── utils.ts              # Utility functions (cn, formatters)
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ admin/ui/
β”‚   β”‚   β”œβ”€β”€ components/       # Breadcrumbs, notifications, search, signout
β”‚   β”‚   β”œβ”€β”€ config/           # Nav config, search config (RBAC)
β”‚   β”‚   └── layout/           # Admin layout, app sidebar, header
β”‚   └── auth/ui/
β”‚       β”œβ”€β”€ form/             # Login, register, forgot & reset password forms
β”‚       └── layout/           # Auth layout (animated gradient bg)
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ migrations/           # Database migrations
β”‚   └── schema.prisma         # Prisma schema
β”œβ”€β”€ trpc/
β”‚   β”œβ”€β”€ client.tsx            # tRPC client provider + React Query setup
β”‚   β”œβ”€β”€ init.ts               # tRPC procedures (base, protected, admin)
β”‚   β”œβ”€β”€ query-client.ts       # TanStack Query client factory
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   └── _app.ts           # Root tRPC router
β”‚   └── server.tsx            # Server-side tRPC caller + prefetch helpers
β”œβ”€β”€ types/
β”‚   └── index.ts              # NavItem, PermissionCheck types
β”œβ”€β”€ .env.example              # Environment variable template
β”œβ”€β”€ components.json           # shadcn/ui configuration
β”œβ”€β”€ next.config.ts            # Next.js config (React Compiler enabled)
β”œβ”€β”€ prisma.config.ts          # Prisma config (datasource URL)
└── tsconfig.json             # TypeScript config

Adding tRPC Routers

Create a new router in trpc/routers/:

// trpc/routers/example.ts
import { z } from "zod/v4";
import {
  createTRPCRouter,
  baseProcedure,
  protectedProcedure,
} from "@/trpc/init";

export const exampleRouter = createTRPCRouter({
  // Public query
  hello: baseProcedure
    .input(z.object({ name: z.string() }))
    .query(({ input }) => {
      return { greeting: `Hello, ${input.name}!` };
    }),

  // Protected mutation (requires auth)
  create: protectedProcedure
    .input(z.object({ title: z.string() }))
    .mutation(({ ctx, input }) => {
      // ctx.auth contains the user session
      console.log("User:", ctx.auth.user.id);
      return { success: true };
    }),
});

Register it in trpc/routers/_app.ts:

import { createTRPCRouter } from "@/trpc/init";
import { exampleRouter } from "./example";

export const appRouter = createTRPCRouter({
  example: exampleRouter,
});

export type AppRouter = typeof appRouter;

tRPC Usage

After creating a router, you can use it in client components with the TanStack React Query integration.

πŸ“– Full documentation: tRPC + TanStack React Query Usage

Example usage in a client component:

"use client";

import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";

export function ExampleComponent() {
  const trpc = useTRPC();
  const queryClient = useQueryClient();

  // Query
  const { data, isLoading } = useQuery(
    trpc.example.hello.queryOptions({ name: "World" })
  );

  // Mutation
  const createMutation = useMutation(
    trpc.example.create.mutationOptions({
      onSuccess: () => {
        // Invalidate and refetch
        queryClient.invalidateQueries(trpc.example.hello.queryFilter());
      },
    })
  );

  if (isLoading) return <p>Loading...</p>;

  return (
    <div>
      <p>{data?.greeting}</p>
      <button onClick={() => createMutation.mutate({ title: "New Item" })}>
        Create
      </button>
    </div>
  );
}

Example server-side prefetching (SSR) in a server component:

import { trpc, HydrateClient, prefetch } from "@/trpc/server";

export default async function Page() {
  // Prefetch on server β€” zero waterfall
  await prefetch(trpc.example.hello.queryOptions({ name: "World" }));

  return (
    <HydrateClient>
      <ExampleComponent />
    </HydrateClient>
  );
}

πŸ’‘ For more details on useQuery, useMutation, useSuspenseQuery, useInfiniteQuery, and more, visit the official tRPC documentation.


Customization

Enabling Email (Resend)

  1. Uncomment the Resend import and email logic in lib/auth.ts
  2. Add your RESEND_API_KEY to .env
  3. Set requireEmailVerification: true in the auth config

Adding shadcn/ui Components

npx shadcn@latest add [component-name]

Adding New File Upload Routes

Edit app/api/uploadthing/core.ts to add new file routes following the existing pattern.


Deployment

This starter is optimized for deployment on Vercel:

  1. Push your repo to GitHub
  2. Import the project on vercel.com
  3. Add all environment variables from .env.example
  4. Update BETTER_AUTH_URL and NEXT_PUBLIC_URL to your production domain
  5. Deploy πŸš€

Special Thanks

This project was made possible by the following amazing open-source projects, tools, and resources:

Core Framework & Libraries

Library Description
Next.js The React framework for the web
React Library for building user interfaces
TypeScript Typed JavaScript at any scale
Tailwind CSS Utility-first CSS framework
shadcn/ui Beautiful, accessible UI components
Radix UI Unstyled, accessible UI primitives

Backend & Data

Library Description
Better Auth Authentication library for Next.js
Prisma Next-generation ORM for Node.js
tRPC End-to-end type-safe APIs
TanStack React Query Powerful data synchronization
UploadThing File uploads made easy
Resend Modern email sending API
Zod TypeScript-first schema validation
SuperJSON Serialization for complex types

UI & Animation

Library Description
GSAP Professional-grade animation library
Recharts Composable charting library for React
Lucide React Beautiful & consistent icon toolkit
Sonner Opinionated toast notifications
Embla Carousel Lightweight carousel library
Vaul Drawer component for React
cmdk Command palette component
next-themes Theme management for Next.js
React Hook Form Performant form handling
react-day-picker Date picker component
react-resizable-panels Resizable panel layouts
input-otp One-time password input component

Sidebar Inspiration

The admin sidebar implementation in this project is inspired by and credits go to:

πŸ”— next-shadcn-dashboard-starter by Kiranism

A beautifully crafted admin dashboard starter with shadcn/ui and Next.js.

Useful Tools & Resources

Resource Description
favicon.io Generate favicons from text, image, or emoji
tweakcn Visual theme editor for shadcn/ui β€” customize colors and styles
Aceternity UI Beautiful animated components for React & Tailwind CSS

PRD Generator

Starter kit ini menyertakan file PRD.md yang berisi prompt template untuk generate Product Requirements Document yang lengkap dan implementation-ready.

Cara Penggunaan

  1. Buka file PRD.md
  2. Copy seluruh isi file tersebut
  3. Paste ke AI tool favoritmu (ChatGPT, Claude, Gemini, dll.)
  4. Isi bagian Project Input dengan detail proyekmu β€” ganti semua {{placeholder}} dengan informasi yang sesuai
  5. AI akan generate PRD lengkap dengan struktur:
    • Overview, User Personas & Stories
    • Functional & Non-Functional Requirements (MoSCoW)
    • Core Features dengan Acceptance Criteria
    • User Flows (Mermaid flowchart)
    • System Architecture & Sequence Diagram
    • Database Schema & ER Diagram
    • API Design, Tech Stack, Development Phases
    • Testing Strategy

πŸ’‘ Tip: Semakin detail input yang kamu berikan, semakin akurat dan actionable PRD yang dihasilkan.

πŸ“„ Contoh hasil PRD: Lihat PRD-EXAMPLE.md untuk contoh PRD yang sudah di-generate menggunakan prompt template ini.


License

This project is licensed under the MIT License.


β˜• Support

If you find this starter kit helpful, consider supporting me:

Ko-fi Trakteer


Created by Candra Wali Sanjaya