Installation Guide
This guide will walk you through installing OpenForum step by step. Follow these instructions to get your forum running locally for development or testing.
🚀 Quick Installation
1. Clone the Repository
First, clone the OpenForum repository to your local machine:
# Clone the repository
git clone https://github.com/your-username/openforum.git
# Navigate to the project directory
cd openforum
2. Install Dependencies
OpenForum uses pnpm as the preferred package manager for better performance and disk efficiency:
# Install pnpm if you haven't already
npm install -g pnpm
# Install project dependencies
pnpm install
Alternative with npm:
# If you prefer npm
npm install
3. Environment Setup
Create your environment configuration file:
# Copy the example environment file
cp .env.example .env.local
# Or create a new .env.local file
touch .env.local
Add the following essential environment variables to your .env.local file:
# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/openforum"
# Authentication (generate a secure random string)
BETTER_AUTH_SECRET="your-super-secret-key-here-minimum-32-characters"
BETTER_AUTH_URL="http://localhost:3000"
# Email Service (Required for user registration)
AUTH_RESEND_KEY="re_xxxxxxxxxxxxxxxxxxxxx"
# Application Configuration
APP_NAME="OpenForum"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
Generate a secure random string for BETTER_AUTH_SECRET:
# Generate a 32-character random string
openssl rand -base64 32
4. Database Setup
Option A: Local PostgreSQL
-
Install PostgreSQL (if not already installed):
# macOS with Homebrew
brew install postgresql
brew services start postgresql
# Ubuntu/Debian
sudo apt update
sudo apt install postgresql postgresql-contrib
# Windows - Download from postgresql.org -
Create Database:
# Create a new database
createdb openforum
# Or connect to PostgreSQL and create manually
psql postgres
CREATE DATABASE openforum;
\q -
Update Connection String:
DATABASE_URL="postgresql://your-username:your-password@localhost:5432/openforum"
Option B: Cloud Database (Recommended for Production)
Choose a cloud PostgreSQL provider:
Neon (Recommended)
- Sign up at neon.tech
- Create a new project
- Copy the connection string
- Update
DATABASE_URLin your.env.local
Supabase
- Sign up at supabase.com
- Create a new project
- Go to Settings → Database
- Copy the connection string
- Update
DATABASE_URLin your.env.local
Railway
- Sign up at railway.app
- Create a new PostgreSQL service
- Copy the connection string
- Update
DATABASE_URLin your.env.local
5. Run Database Migrations
Generate and apply the database schema:
# Generate migration files (if not already present)
pnpm drizzle-kit generate
# Apply migrations to your database
pnpm drizzle-kit migrate
6. Start Development Server
Launch the development server:
# Start the development server
pnpm dev
Your forum will be available at http://localhost:3000 🎉
📧 Email Service Setup
Email is required for user registration and notifications. OpenForum uses Resend for reliable email delivery.
1. Create Resend Account
- Sign up at resend.com
- Verify your email address
- Go to API Keys in your dashboard
- Create a new API key
- Copy the key (starts with
re_)
2. Configure Environment
Add your Resend API key to .env.local:
AUTH_RESEND_KEY="re_xxxxxxxxxxxxxxxxxxxxx"
3. Test Email Functionality
- Start your development server
- Try registering a new user
- Check that verification emails are sent
- Verify the email verification process works
For production use, you'll need to verify your domain in Resend:
- Add your domain in the Resend dashboard
- Add the required DNS records
- Wait for verification (usually takes a few minutes)
🔐 OAuth Setup (Optional)
Enable social login with Google and GitHub:
Google OAuth
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API:
- Go to APIs & Services → Library
- Search for "Google+ API" and enable it
- Create OAuth 2.0 credentials:
- Go to APIs & Services → Credentials
- Create credentials → OAuth 2.0 Client IDs
- Application type: Web application
- Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google
- Copy credentials and add to
.env.local:
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GitHub OAuth
- Go to GitHub Settings → Developer settings → OAuth Apps
- Create a new OAuth App:
- Application name: Your Forum Name
- Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/api/auth/callback/github
- Copy credentials and add to
.env.local:
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
🔧 Development Tools
Database Management
Drizzle Studio - Visual database browser:
# Open Drizzle Studio
pnpm drizzle-kit studio
Access at http://localhost:4983
Code Quality Tools
Linting:
# Run ESLint
pnpm lint
# Fix linting issues automatically
pnpm lint --fix
Type Checking:
# Run TypeScript type checking
pnpm type-check
Building for Production
# Build the application
pnpm build
# Start production server (after build)
pnpm start
📁 Project Structure Overview
Understanding the project structure:
openforum/
├── app/ # Next.js 15 App Router
│ ├── api/ # API routes and authentication
│ ├── auth/ # Authentication pages
│ ├── forum/ # Main forum pages
│ └── layout.tsx # Root layout
├── components/ # React components
│ ├── auth/ # Authentication forms
│ ├── forum/ # Forum-specific components
│ ├── ui/ # Reusable UI components
│ └── views/ # Page-level view components
├── db/ # Database configuration
│ ├── schema.ts # Drizzle database schema
│ └── drizzle.ts # Database connection
├── lib/ # Utility libraries
│ ├── auth.ts # Better Auth configuration
│ ├── auth-client.ts # Client-side auth utilities
│ └── utils.ts # Helper functions
├── actions/ # Server actions for data operations
├── migrations/ # Database migration files
└── docs/ # Documentation files
🚨 Common Installation Issues
Database Connection Issues
Error: connection refused
# Check if PostgreSQL is running
brew services list | grep postgresql
# Start PostgreSQL if not running
brew services start postgresql
Error: database does not exist
# Create the database
createdb openforum
Error: authentication failed
- Check your username and password in
DATABASE_URL - Ensure the user has proper permissions
Node.js Version Issues
Error: unsupported Node.js version
# Check your Node.js version
node --version
# Update Node.js if needed (using nvm)
nvm install 18
nvm use 18
Permission Issues
Error: EACCES permission errors
# Fix npm permissions (macOS/Linux)
sudo chown -R $(whoami) ~/.npm
# Or reinstall Node.js with proper permissions
✅ Verification Checklist
After installation, verify these features work:
- Development server starts without errors
- Homepage loads at http://localhost:3000
- Database connection works (check logs)
- User registration form appears
- Email verification emails are sent (if configured)
- OAuth login buttons appear (if configured)
- Admin panel is accessible at
/forum/admin
🔗 Next Steps
Now that OpenForum is installed:
- First Steps Guide - Set up your first admin account and categories
- Configuration Guide - Advanced configuration options
- Deployment Guide - Deploy to production
Installation complete! 🎉 Ready to set up your forum? Continue to First Steps.