Local Development
This guide will help you get PocketKit running on your local machine.
Prerequisites
Section titled “Prerequisites”Before you begin, make sure you have the following installed:
- Node.js (v18 or higher)
- Package manager (npm, yarn, or pnpm)
- Git
Quick Setup (Recommended)
Section titled “Quick Setup (Recommended)”The fastest way to get started is using the automated setup script:
# Clone the repositorygit clone https://github.com/stijnbakk/PocketKit.gitcd PocketKit
# Run the get started script./GET-STARTED.shThe script will prompt you to choose between:
- SvelteKit (
app-sveltedirectory) - React/Next.js (
app-reactdirectory)
Then it will automatically:
- Initialize a fresh git repository
- Install dependencies (auto-detects pnpm/yarn/npm)
- Download PocketBase for your operating system
- Create an initial commit
Once complete, start developing:
# For SvelteKitcd app-svelteyarn dev
# For React/Next.jscd app-reactyarn dev# For SvelteKitcd app-sveltepnpm dev
# For React/Next.jscd app-reactpnpm dev# For SvelteKitcd app-sveltenpm run dev
# For React/Next.jscd app-reactnpm run devManual Setup
Section titled “Manual Setup”If you prefer to set up manually or the script doesn’t work for your system, follow these steps.
Project Structure
Section titled “Project Structure”PocketKit provides two frontend options:
PocketKit/├── app-svelte/ # SvelteKit frontend application├── app-react/ # Next.js frontend application├── server/ # PocketBase backend (shared by both)└── docs/ # Documentation (Starlight)Choose one app directory based on your preferred framework.
Install Dependencies
Section titled “Install Dependencies”Navigate to your chosen app directory and install the dependencies:
# For SvelteKitcd app-svelteyarn install
# OR for React/Next.jscd app-reactyarn install# For SvelteKitcd app-sveltepnpm install
# OR for React/Next.jscd app-reactpnpm install# For SvelteKitcd app-sveltenpm install
# OR for React/Next.jscd app-reactnpm installDownload PocketBase
Section titled “Download PocketBase”For local development, you need to download the PocketBase executable:
- Visit pocketbase.io
- Download the appropriate version for your operating system
- Place the
pocketbaseexecutable in theserver/directory
Note: Make sure the file is named pocketbase and is executable.
On macOS/Linux, you may need to make it executable:
chmod +x ../server/pocketbaseStart Development Server
Section titled “Start Development Server”From your chosen app directory, run:
SvelteKit:
cd app-svelteyarn devcd app-sveltepnpm devcd app-sveltenpm run devThis single command will:
- Start the SvelteKit dev server on
http://localhost:5173 - Launch PocketBase on
http://localhost:8090
React/Next.js:
cd app-reactyarn devcd app-reactpnpm devcd app-reactnpm run devThis single command will:
- Start the Next.js dev server on
http://localhost:3000 - Launch PocketBase on
http://localhost:8090
Access the Application
Section titled “Access the Application”Once both servers are running:
SvelteKit:
- Frontend: http://localhost:5173
- PocketBase Admin: http://localhost:8090/_
React/Next.js:
- Frontend: http://localhost:3000
- PocketBase Admin: http://localhost:8090/_
Set Up PocketBase Admin
Section titled “Set Up PocketBase Admin”On first run, you’ll need to create an admin account:
- Visit http://localhost:8090/_
- Create your admin email and password
- This account is for managing your backend (users, collections, settings)
Environment Variables
Section titled “Environment Variables”Both apps use environment variables for configuration.
SvelteKit - Create .env in the app-svelte/ directory:
PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090React/Next.js - Create .env.local in the app-react/ directory:
NEXT_PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090Development Workflow
Section titled “Development Workflow”Making Changes
Section titled “Making Changes”Frontend code: Edit files in your chosen app directory - changes will hot reload automatically
- SvelteKit:
app-svelte/src/ - Next.js:
app-react/src/
Backend:
- Schema: Use the PocketBase admin UI at http://localhost:8090/_
- Hooks: Add JavaScript/TypeScript files to
server/pb_hooks/(requires PocketBase restart)
Database
Section titled “Database”PocketBase uses SQLite and stores all data in server/pb_data/. This directory is created automatically when you first run PocketBase.
Testing Authentication
Section titled “Testing Authentication”Both apps include complete auth flows:
SvelteKit:
- Register: http://localhost:5173/auth/register
- Login: http://localhost:5173/auth/login
- Logout: Handled via the logout endpoint
React/Next.js:
- Register: http://localhost:3000/auth/register
- Login: http://localhost:3000/auth/login
- Logout: Click the logout button (handled via API route)
Create a test user to verify everything works.
Common Issues
Section titled “Common Issues”Port Already in Use
Section titled “Port Already in Use”If port 5173 or 8090 is already in use:
- SvelteKit: Stop the process using port 5173, or modify the port in
vite.config.ts - PocketBase: Stop any running PocketBase instances, or modify the port in the dev script
PocketBase Not Found
Section titled “PocketBase Not Found”If you get an error about PocketBase not being found:
- Make sure you downloaded the PocketBase executable
- Verify it’s in the
server/directory - Ensure it’s named
pocketbase(no file extension on macOS/Linux) - Verify it’s executable (
chmod +x server/pocketbaseon macOS/Linux)
Permission Denied (macOS)
Section titled “Permission Denied (macOS)”On macOS, you might see a security warning when running PocketBase:
- Go to System Settings → Privacy & Security
- Look for a message about PocketBase being blocked
- Click Allow Anyway
- Run the dev command again
Next Steps
Section titled “Next Steps”Now that you have PocketKit running locally:
- Explore the Authentication system to understand how auth works
- Learn how to Deploy to production
- Start building your app:
- SvelteKit: Modify files in
app-svelte/src/routes/ - Next.js: Modify files in
app-react/src/app/
- SvelteKit: Modify files in