10000 GitHub - kacperkwapisz/pocketnext: ⚑ Minimalist Next.js + PocketBase starter with TypeScript, Tailwind CSS, and Docker support
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

⚑ Minimalist Next.js + PocketBase starter with TypeScript, Tailwind CSS, and Docker support

License

Notifications You must be signed in to change notification settings

kacperkwapisz/pocketnext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PocketNext

PocketNext CLI Demo

npm version npm downloads license PRs welcome Next.js 15 PocketBase

A minimalist, production-ready starter for building full-stack applications with Next.js and PocketBase.

πŸ“‹ Table of Contents

πŸš€ Quick Start

Using the CLI (Recommended)

# Create a new project using bunx
bunx pocketnext@latest my-app

# OR use bun create (recommended)
bun create pocketnext my-app

# Navigate to your project
cd my-app

# Start the development environment
bun dev

Project Profiles

PocketNext offers a streamlined project creation experience with pre-configured profiles:

Profile Description
Minimal Basic setup with essential features only
Standard Recommended setup for most projects (default)
Production Full setup with CI/CD and deployment configuration
Custom Choose each option individually

You can select a profile during the interactive setup or specify it directly:

# Create a project with minimal configuration
bunx pocketnext@latest my-app --profile=minimal

# Create a production-ready project
bunx pocketnext@latest my-app --profile=production

# Quick setup with sensible defaults
bunx pocketnext@latest my-app --quick

CLI Options

All commands support these options:

Option Description
--profile=<profile> Select project setup profile (minimal, standard, production, custom)
--quick Quick setup with minimal prompts
--use-npm/yarn/pnpm/bun Choose a package manager
-y, --yes Skip interactive prompts and use defaults
--skip-install Skip package installation
--scripts <option> Automate PocketBase setup (runAndKeep or runAndDelete)
--pb-version <version> Install specific PocketBase version
--help Show all available options
# Example with multiple options
bunx pocketnext@latest my-app --profile=production --use-bun --skip-install

Manual Setup

# Clone the repository
git clone https://github.com/kacperkwapisz/pocketnext.git
cd pocketnext

# Option 1: Copy the template folder to your project location
cp -r templates/default /path/to/your-project
cd /path/to/your-project

# Option 2: Or use the CLI directly from the repository
bun install
bun build
bun start my-app  # This runs the CLI to create a new project

# After either option, set up the project
cd my-app  # If using Option 2
bun install
bun setup  # Downloads PocketBase
bun dev    # Start development environment

Visit:

🧰 Core Features

Feature Description
⚑ Next.js 15 Latest version with App Router
πŸ”„ PocketBase Backend Database, auth, file storage, and real-time API
🎨 Tailwind CSS Utility-first CSS framework
πŸ” TypeScript Full type safety for your codebase
πŸ› οΈ Dev Tools Live reload for both frontend and backend
πŸ’» Interactive CLI Customizable project creation
πŸ“± Responsive Design Mobile-first approach
πŸ”’ Authentication Built-in auth system via PocketBase
πŸ”₯ Hot Reload Fast refresh for rapid development
πŸ—οΈ Robust Setup Multi-strategy template handling for reliability

πŸ“¦ Installation Methods

PocketNext can be installed in several ways:

# Using bun (recommended)
bun create pocketnext my-app

# Using bunx
bunx pocketnext@latest my-app

# Using npx
npx pocketnext@latest my-app

πŸ“„ Project Structure

CLI Project Structure

pocketnext/
β”œβ”€β”€ src/                # Source code for CLI
β”‚   β”œβ”€β”€ core/           # Core functionality
β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   └── types/          # TypeScript types
β”œβ”€β”€ templates/          # Project templates
β”œβ”€β”€ public/             # Static assets
β”œβ”€β”€ scripts/            # Helper scripts
└── dist/               # Compiled CLI code (generated)

Generated Project Structure

your-project/
β”œβ”€β”€ public/             # Static assets
β”œβ”€β”€ scripts/            # Helper scripts
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/            # Next.js application with App Router
β”‚   β”‚   β”œβ”€β”€ api/        # API routes
β”‚   β”‚   β”œβ”€β”€ auth/       # Auth-related pages
β”‚   β”‚   └── (routes)/   # Application routes
β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”œβ”€β”€ ui/         # UI components
β”‚   β”‚   └── layout/     # Layout components
β”‚   └── lib/            # Shared utilities
β”‚       └── pocketbase/ # PocketBase client & types
β”œβ”€β”€ pocketbase/         # PocketBase binary (generated)
β”œβ”€β”€ .env                # Environment variables
└── docker-compose.yml  # Docker configuration (if selected)

πŸ”§ Available Commands

Command Description
bun dev Start Next.js and PocketBase for development
bun dev:next Start only Next.js development server
bun dev:pb Start only PocketBase server
bun dev:pb:admin Start PocketBase with admin setup prompt
bun build Build Next.js for production
bun start Start Next.js production server
bun setup Install dependencies and download PocketBase
bun setup:db Only download PocketBase
bun setup:admin Set up PocketBase admin credentials interactively
bun typegen Generate TypeScript types from PocketBase schema
bun lint Run ESLint to check code quality

πŸ” Setting Up PocketBase Admin

For security reasons, the default PocketBase setup doesn't include admin credentials. You have several options:

  1. Interactive Setup:

    bun setup:admin

    This will prompt you for admin email and password, with an option to save to your .env file.

  2. Run with Admin Prompt:

    bun dev:pb:admin

    Similar to above but runs PocketBase after setup.

  3. Use Environment Variables: Add to your .env file:

    PB_ADMIN_EMAIL=your-email@example.com
    PB_ADMIN_PASSWORD=your-secure-password
    

    Then run with admin mode: bun dev:pb:admin

  4. First-Run Setup: Just run PocketBase normally and create admin account through the web UI:

    bun dev:pb

    Then visit http://localhost:8090/\_/ and follow the setup instructions.

πŸ›  Advanced Features (Optional)

🐳 Docker Deployment

This project includes a production-ready Docker setup for deployment.

# Copy the example environment file
cp .env.example .env

# Build and start containers
docker-compose up -d

The Docker setup provides:

  • Separate containers for Next.js and PocketBase
  • Health checks for reliability
  • Volume mounting for persistent data
  • Environment variable configuration
🚒 CI/CD with GitHub Actions

Pre-configured GitHub workflows for continuous integration and deployment:

  • CI Workflow: Builds and tests your application
  • Deployment to Coolify: Automatically deploys to Coolify hosting

To enable Coolify deployment:

  1. Add COOLIFY_WEBHOOK and COOLIFY_TOKEN secrets to your GitHub repository
  2. Use the docker-compose.coolify.yml in your Coolify configuration
πŸ§ͺ Type Generation

Generate TypeScript types from your PocketBase schema:

bun typegen

This creates types in src/lib/pocketbase/types.ts for type-safe database operations.

πŸ”„ Real-time Subscriptions

PocketBase offers real-time subscriptions to collection changes:

// In your Next.js component
import { pb } from "@/lib/pocketbase";

// Subscribe to changes
const unsubscribe = pb.collection("posts").subscribe("*", (data) => {
  console.log("New data received:", data);
  // Update your UI with the new data
});

// Clean up when done
useEffect(() => {
  return () => unsubscribe();
}, []);

This enables building reactive applications that update in real-time.

πŸ“ Development

πŸ“œ Changelog

See the CHANGELOG.md for a detailed list of changes in each version.

πŸ§‘β€πŸ’» Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add some amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

❓ Troubleshooting

Common Issues

PocketBase fails to start

Check if port 8090 is already in use:

lsof -i :8090

If so, you can change the port in the .env file:

PB_PORT=8091

Next.js build fails

If you encounter issues during build, ensure all dependencies are installed:

bun install

Also check for any TypeScript errors:

bun typecheck

Template fetching issues

If you encounter problems with template fetching:

  1. Ensure you have Git installed and available in your PATH
  2. Check your internet connection
  3. If you're behind a firewall or proxy, try using the --quick flag which uses simpler fetching strategies
  4. As a last resort, you can manually clone the repository and copy the template directly:
# Clone the repository
git clone https://github.com/kacperkwapisz/pocketnext.git

# Copy the template to your project location
cp -r pocketnext/templates/default my-app

# Navigate to your project and set it up
cd my-app
bun install
bun setup:db  # Download PocketBase

Type errors with PocketBase collections

If you're experiencing type errors when accessing PocketBase collections, regenerate the types:

bun typegen

πŸ“š Learn More

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

0