Quickstart Guide
Get your development environment set up and running in just a few minutes. This guide will walk you through cloning the repository, setting up the database, and running your first authenticated API call.Prerequisites
Before you begin, make sure you have the following installed:- Node.js 20+: Download Node.js
- pnpm: Fast, disk space efficient package manager
Installation
Install Dependencies
Install all required packages using pnpm:This will install all dependencies including:
- ORPC packages (
@orpc/server,@orpc/client,@orpc/tanstack-query) - Better Auth for authentication
- Drizzle ORM and libsql client
- Next.js and React
- UI dependencies (Tailwind CSS, shadcn/ui components)
Set Up Environment Variables
Copy the example environment file and configure your variables:The default configuration works for local development:
.env
For production, you’ll need to add
BETTER_AUTH_SECRET and BETTER_AUTH_URL. See the Installation guide for details.Initialize the Database
Start the local SQLite database and apply the schema:In another terminal, push the schema to your database:This creates the necessary tables for:
- User authentication (users, sessions, accounts)
- Todo application (todos table)
The
db:local command uses Turso’s local development server. Keep this terminal running while you develop.Start the Development Server
Launch the Next.js development server with Turbopack:Your application will be available at http://localhost:3000
The development server uses Turbopack for fast hot module replacement (HMR).
Verify Your Setup
Let’s make sure everything is working correctly:Test the Application
Open your browser and navigate to http://localhost:3000You should see the landing page with navigation to different sections.
Create an Account
- Click on Sign Up or navigate to
/login - Enter an email address and password
- Click Create Account
- Hash your password securely using bcrypt
- Create a user record in the database
- Establish a session with secure cookies
Try Protected Procedures
Navigate to the Dashboard or You should see your user information displayed, proving that authentication is working.
/dashboard page.This page calls a protected procedure that requires authentication:src/routers/index.ts
Understanding the Data Flow
Here’s what happens when you call an ORPC procedure:Next Steps
Core Concepts
Learn how ORPC procedures and Better Auth work together
API Reference
Explore all available procedures and their types
Database Schema
Understand the database structure and migrations
Deployment
Deploy your application to production
Common Issues
Port 3000 already in use
Port 3000 already in use
If port 3000 is already in use, you can change it in Don’t forget to update
package.json:NEXT_PUBLIC_SERVER_URL in your .env file.Database connection errors
Database connection errors
Make sure:
- The
db:localcommand is running in a separate terminal - The
DATABASE_URLin.envmatches the database location - You’ve run
pnpm db:pushto create the tables
Type errors in the client
Type errors in the client
If you see TypeScript errors when calling ORPC procedures:
- Restart your TypeScript server in your editor
- Make sure your imports match the router structure
- Check that
AppRoutertype is exported fromsrc/routers/index.ts
Authentication not persisting
Authentication not persisting
Better Auth uses HTTP-only cookies for sessions. Make sure:
- You’re not blocking cookies in your browser
- The
credentials: "include"option is set in the fetch configuration (already configured in the template) - Your
NEXT_PUBLIC_SERVER_URLmatches the URL you’re accessing
Development Tips
- Hot Reload: Changes to your ORPC router automatically update types in your client code
- Database Studio: Run
pnpm db:studioto open Drizzle Studio and inspect your database - React Query DevTools: The template includes React Query DevTools - look for the icon in the bottom corner
- Type Checking: Run
pnpm typecheckto check for TypeScript errors across your project - Linting: Run
pnpm lintto check code quality with Biome
Ready to Build
You now have a fully functional type-safe API with authentication! Start building your features by:- Adding new procedures to your ORPC routers
- Creating new database tables in
src/db/schema - Building UI components with shadcn/ui
- Implementing your business logic