Installation
Get started with this T3 + Cloudflare starter template in just a few minutes.
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js 20.x or later
- npm 10.x or later (comes with Node.js)
- Git for version control
Clone the Repository
First, clone the repository to your local machine:
git clone https://github.com/yourusername/yourproject.git
cd yourprojectInstall Dependencies
Install all required dependencies using npm:
npm installThis will install all packages listed in package.json, including:
- Next.js framework
- Drizzle ORM for database
- NextAuth.js for authentication
- Stripe for payments
- shadcn/ui components
Environment Setup
Create a .env file in the root directory by copying the example:
cp .env.example .envOpen .env and configure the following essential variables:
# Database
DATABASE_URL="file:./local.db"
# Authentication
AUTH_SECRET="your-secret-key-here"
NEXTAUTH_URL="http://localhost:3000"
# Stripe (optional for development)
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_test_..."
# Email (optional for development)
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="your-email@gmail.com"
SMTP_PASSWORD="your-app-password"Generate AUTH_SECRET
Generate a secure random string for AUTH_SECRET:
openssl rand -base64 32Database Setup
Initialize your database with Drizzle:
# Generate migrations
npm run db:generate
# Apply migrations
npm run db:pushRun Development Server
Start the development server:
npm run devOpen http://localhost:3000 in your browser to see your application.
Verify Installation
To verify everything is working correctly:
- Visit http://localhost:3000 - you should see the home page
- Navigate to /register - you should see the registration page
- Check the console for any errors
Next Steps
Now that you have everything installed, proceed to:
- Configuration - Configure your application
- Deployment - Deploy to Cloudflare Pages
Troubleshooting
Port Already in Use
If port 3000 is already in use, you can start the dev server on a different port:
npm run dev -- -p 3001Database Connection Errors
If you encounter database connection errors:
- Ensure
DATABASE_URLis correctly set in.env - Delete
local.dband runnpm run db:pushagain - Check file permissions
Module Not Found Errors
If you see “module not found” errors:
- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Restart your development server