Prerequisites
Before setting up PocketKit, ensure you have the following installed:
- Node.js (latest LTS version recommended)
- Docker and Docker Compose
Installation Steps
Clone the PocketKit repository
git clone https://github.com/your-pocketkit-repo-url.git cd pocketkitInstall dependencies
npm installSet up environment variables
Create a
.envfile in the root directory based on the.env.examplefile. Add the following variables:PUBLIC_POCKETBASE_URL=http://127.0.0.1:8090/ PADDLE_API_KEY=your_paddle_api_key PADDLE_SECRET=your_paddle_secret PUBLIC_PADDLE_TOKEN=your_public_paddle_token APP_SECRET=your_app_secretReplace
your_paddle_api_key,your_paddle_secret, andyour_public_paddle_tokenwith your actual Paddle credentials. Replaceyour_app_secretwith a random string. Visit webhooksite to get a webhook tokenExplanation of variables:
PUBLIC_POCKETBASE_URL: The URL where PocketBase is accessible (both server-side and client-side)PADDLE_API_KEY: Your Paddle API key for payment processing, reading user subscriptions etcPADDLE_SECRET: Your Paddle secret for webhook verificationPUBLIC_PADDLE_TOKEN: Your public Paddle token for client-side Paddle.js initializationAPP_SECRET: A secret key used for various security purposes, including CSRF protection and hashing.
Note: Ensure that your PocketBase instance is running on the specified URL. You may need to adjust this URL based on your specific setup or production environment.
Start the development environment
docker-compose up -dThis will start PocketBase and MailHog containers as defined in the
docker-compose.yamlfile.Run the development server
npm run devThis will start the SvelteKit development server.
Accessing Services
- PocketBase Admin UI: http://localhost:8090/_/
- MailHog UI: http://localhost:8025
- Your PocketKit App: http://localhost:5173 (or the port specified by SvelteKit)
Configuration
PocketBase
PocketBase is configured to use the following:
- Public directory:
./pocketbase/pb_public - Hooks directory:
./pocketbase/pb_hooks - Migrations directory:
./pocketbase/pb_migrations
The Paddle secret is passed to PocketBase as an environment variable.
OAuth2 settings
See Pocketbase documentation for more details on how to set up OAuth2. https://pocketbase.io/docs/authentication#oauth2-integration
Mail settings
For local development, you can use MailHog to intercept emails sent by your application.
Login to PocketBase at http://localhost:8090/_/ and go to Settings > Mail > SMTP.
Set the SMTP server to 172.17.0.1 and the port to 1025.
MailHog
MailHog is set up to intercept emails sent by your application during development. You can view these emails in the MailHog UI.