A modern full-stack template that combines the power of Next.js, the simplicity of PocketBase, and the beauty of shadcn/ui. Perfect for quickly bootstrapping production-ready web applications with authentication and a polished UI.
- π Next.js 15+ App Router
- π¦ PocketBase backend with built-in authentication
- π¨ Beautiful UI components from shadcn/ui
- π Server-side rendering and client-side interactivity
- π Form handling with React Server Actions
- π Complete authentication system with email/password
- π³ Production-ready Docker setup
- βοΈ One-command deployment to Fly.io
- π Secure cookie-based authentication
- π‘οΈ Type-safe development with TypeScript
- β‘ Bun for fast package management and running scripts
- Bun runtime
- Fly.io CLI (for deployment)
- Clone the repository:
git clone https://github.com/yourusername/pocketwatcher.git
cd pocketwatcher
- Install dependencies:
bun install
- Start the development servers:
In one terminal, start PocketBase:
./pocketbase serve
In another terminal, start the Next.js development server:
bun run dev
- Access the applications:
- Next.js: http://localhost:3000
- PocketBase Admin: http://localhost:8090/\_/
- Install the Fly.io CLI:
curl -L https://fly.io/install.sh | sh
fly auth login
- Deploy the application:
bun run launch
You can either accept the defaults by selecting "No" when asked to tweak settings, or customize them according to your needs.
-
During deployment, you'll be prompted twice:
- When asked "Do you want to tweak these settings before proceeding?" β Type
No
- When asked "Would you like to allocate dedicated ipv4 and ipv6 addresses now?" β Type
Yes
- When asked "Do you want to tweak these settings before proceeding?" β Type
-
After deployment, find your PocketBase admin setup URL:
fly logs | grep pbinstal
- Access the admin setup URL by replacing:
- Change
http://0.0.0.0:8090
tohttps://your-app-name.fly.dev:8091
- Keep the rest of the URL path and token
- Change
Your app will be available at:
- Secure login system with email/password
- User registration with password confirmation
- Server-side form validation
- Protected routes and authenticated sessions
- Secure cookie handling
- Automatic redirects after authentication
- Error handling and user feedback
- Type-safe authentication actions
βββ src/
β βββ app/ # Next.js application
β β βββ actions/ # Server actions
β β βββ api/ # API routes
β β βββ auth/ # Authentication pages
β β βββ page.tsx # Home page
β βββ components/ # React components
β β βββ ui/ # shadcn/ui components
β β βββ auth/ # Authentication components
β βββ lib/ # Utility functions and configs
βββ public/ # Static assets
βββ pb_data/ # PocketBase data directory
βββ Dockerfile # Production Docker configuration
- User enters credentials on login/register page
- Form data is processed by server actions
- PocketBase validates credentials
- On success:
- Auth token is stored in HTTP-only cookie
- User is redirected to dashboard
- On error:
- User receives feedback message
- Form remains interactive
- HTTP-only cookies for token storage
- Server-side validation
- Password confirmation on registration
- Secure password handling
- Protected API routes
- Type-safe authentication flow
- CSRF protection with Next.js
- Secure session management
The fly.toml
configuration file sets up:
- App name and organization
- Region configuration
- Machine specifications (shared-cpu-1x, 1GB RAM)
- Service ports for PocketBase (8090/8091) and Next.js (3000)
- Volume mounts for persistent PocketBase data
Supervisor manages both services in production:
- Next.js application
- PocketBase server
- Process monitoring and automatic restarts
- Log management
Multi-stage build process that:
- Builds the Next.js application
- Sets up PocketBase
- Configures the production environment
- Handles service orchestration
Contributions are welcome! Please feel free to submit a Pull Request.
MIT