You're just a few minutes away from having a chat app powered by self-hosted Convex.
This project supports three deployment options:
- GitHub Codespaces (recommended) - Fully automated setup
- Local Development Container - Consistent local environment
- Local Development - Direct local setup
- Getting Started
- GitHub Codespaces Setup
- Local Development Container
- Local Development Setup
- Development Commands
- Accessing Services
- Troubleshooting
- Security Note
This project is configured to work seamlessly with GitHub Codespaces with fully automated setup.
- Open in Codespaces: Click the "Code" button on GitHub and select "Create codespace on main"
- Wait for setup: The post-create script will automatically:
- Install dependencies with pnpm
- Create environment files from examples
- Configure Codespace URLs for ports 3210 and 3211
- Set ports 3210 and 5173 to public
- Start Docker containers
- Generate admin key
- Deploy Convex functions
- Stop Docker containers (ready for development)
- Start development: Once setup is complete, run:
Note: The post-start script will automatically start Docker containers when the Codespace restarts.
pnpm run docker:up # Start the Convex backend pnpm dev # Start the Vite development server
The following ports are automatically forwarded and configured:
- 5173: Vite development server (your React app)
- 3210: Convex self-hosted backend
- 6791: Convex dashboard
Once the development server is running:
- Click on the "Ports" tab in VS Code
- Click the globe icon next to port 5173 to open your app
- The Convex dashboard will be available on port 6791
If you prefer to run the development container locally:
- Prerequisites: Ensure Docker Desktop is running
- Open in VS Code: Open this project in VS Code with the Dev Containers extension
- Reopen in Container: VS Code will prompt to reopen in container, or use
Ctrl+Shift+P→ "Dev Containers: Reopen in Container" - Wait for setup: The post-create script will automatically:
- Install dependencies with pnpm
- Create environment files from examples
- Start Docker containers
- Generate admin key
- Deploy Convex functions
- Stop Docker containers (ready for development)
- Start development: Once setup is complete, run:
Note: The post-start script will automatically start Docker containers when the container restarts.
pnpm run docker:up # Start the Convex backend pnpm dev # Start the Vite development server
For direct local development without containers:
pnpm installCopy and edit the environment files:
cp .env.local.example .env.local
cp .env.docker.example .env.dockerEdit .env.docker:
- Change
INSTANCE_SECRETto a secure value (do not use the default for production!) - Adjust ports if needed
Edit .env.local:
- Set the self-hosted URL:
VITE_CONVEX_URL=http://localhost:3210 CONVEX_SELF_HOSTED_URL=http://localhost:3210 # CONVEX_SELF_HOSTED_ADMIN_KEY= (will be set automatically)
Run the post-create setup script manually:
pnpm run self-hosted:setup-manualThis will:
- Create environment files if they don't exist
- Start Docker containers
- Generate an admin key and update
.env.local - Deploy Convex functions
- Stop Docker containers
pnpm run docker:up # Start the Convex backend
pnpm dev # Start the Vite development serverNote: You need to run both commands - the Docker containers for the Convex backend and the Vite development server separately.
pnpm dev- Start Vite development server (frontend only)pnpm run docker:up- Start self-hosted Convex backend (Docker)pnpm run docker:down- Stop Docker containerspnpm run docker:logs- View logs from Docker containerspnpm run docker:generate-admin-key- Generate admin key for self-hosted backendpnpm run deploy-functions- Deploy Convex functions to self-hosted backendpnpm run build- Build frontend for productionpnpm run self-hosted:setup-manual- Run post-create setup manually
All scripts use
pnpm. If you encounter issues, ensure you are usingpnpmfor installing dependencies and running commands.
- Frontend: http://localhost:5173
- Convex Backend: http://localhost:3210
- Convex Dashboard: http://localhost:6791
- Port conflicts: If ports 3210, 3211, or 6791 are in use, modify them in
.env.docker - Connection issues: Ensure Docker services are healthy by checking
pnpm run docker:logs - Frontend not connecting: Verify
VITE_CONVEX_URLin.env.localmatches your backend configuration - Authentication errors: Make sure you've generated and configured the admin key properly
- Missing functions: After switching to self-hosted, redeploy with
pnpm run deploy-functions - Build issues:
- Clear node_modules:
rm -rf node_modules && pnpm install - Clear Convex cache:
pnpm run deploy-functions - Restart both the Docker containers and development server
- Clear node_modules:
- Data persistence: Docker volumes are used for backend data. To reset:
docker compose down -v # Removes volumes and all data!
# Generate a new admin key
pnpm run docker:generate-admin-key
# View backend logs
pnpm run docker:logs
# Export data before migration
pnpm run convex export --path backup.zip
# Import data after setup
pnpm run convex import --replace-all backup.zipAlways change the INSTANCE_SECRET in .env.docker before deploying to any non-local environment!