**Full-stack starter kit** with SvelteKit + PocketBase integrated from the beginning.
npm install create-onestackFull-stack starter kit with SvelteKit + PocketBase integrated from the beginning.
> The goal of FStack is to provide a ready-to-use full-stack development environment similar to create-next-app, but with PocketBase as the backend ā everything connected out of the box.
Download PocketBase from pocketbase.io and run:
``bash`
./pocketbase serve
This starts the backend at http://127.0.0.1:8090
Create an admin account at http://127.0.0.1:8090/_/
`bash`
cd my-app
npm install
npm run dev
This starts the frontend at http://localhost:5173
Run the setup script to automatically create all required collections:
`bash`
npm run setup
This will:
- ā
Connect to PocketBase
- ā
Authenticate as admin (prompts for credentials)
- ā
Create the test_items collection with proper fields
- ā
Configure API rules for authenticated access
Using environment variables (CI/CD):
`bash`
PB_URL=http://127.0.0.1:8090 PB_ADMIN_EMAIL=admin@example.com PB_ADMIN_PASS=yourpassword npm run setup
Open your browser and navigate to http://localhost:5173. The test dashboard will show you the status of all PocketBase integrations ā all tests should pass!
If you prefer to manually create collections, add a test_items collection in PocketBase Admin (http://127.0.0.1:8090/_/):
| Field | Type |
|-------------|------|
| title | Text |description
| | Text |status
| | Text |
> Tip: Set API Rules to @request.auth.id != "" for all operations.
``
my-app/
āāā scripts/
ā āāā setup-db.ts # Auto-provision database collections
āāā src/
ā āāā lib/
ā ā āāā pocketbase.ts # PocketBase client & helper functions
ā ā āāā test-utils.ts # Test utilities and types
ā ā āāā setup/ # Setup & provisioning module
ā ā āāā schemas.ts # Collection schema definitions
ā ā āāā provision.ts # Provisioning logic
ā ā āāā index.ts # Module exports
ā āāā routes/
ā āāā +page.svelte # Integration test dashboard
āāā package.json
āāā README.md
Import the pre-configured client anywhere in your app:
`typescript
import { pb, isAuthenticated, getCurrentUser } from '$lib/pocketbase';
// Check authentication
if (isAuthenticated()) {
const user = getCurrentUser();
console.log('Logged in as:', user?.email);
}
// Fetch records
const posts = await pb.collection('posts').getList(1, 20);
// Subscribe to changes
pb.collection('posts').subscribe('*', (e) => {
console.log('Change:', e.action, e.record);
});
`
`typescript
// Health & Connection
checkHealth() // Check if PocketBase is reachable
// Authentication
isAuthenticated() // Check if user is logged in
getCurrentUser() // Get current user record
registerUser(email, password, passwordConfirm, name?)
loginWithEmail(email, password)
logout()
requestPasswordReset(email)
requestEmailVerification(email)
// CRUD Operations
createRecord(collection, data)
getRecord(collection, id)
updateRecord(collection, id, data)
deleteRecord(collection, id)
listRecords(collection, page?, perPage?, filter?, sort?)
// Realtime
subscribeToCollection(collection, callback)
subscribeToRecord(collection, recordId, callback)
// Files
getFileUrl(record, filename, queryParams?)
uploadFile(collection, recordId, fieldName, file)
// Utilities
collectionExists(collectionName)
// Setup & Provisioning
provisionCollections(options) // Auto-create collections
checkPocketBaseHealth(url) // Verify server is running
`
Define your collection schemas in src/lib/setup/schemas.ts:
`typescript
import { createCollectionSchema, DEFAULT_COLLECTIONS } from '$lib/setup';
// Add your custom collection
const postsCollection = createCollectionSchema('posts', [
{ name: 'title', type: 'text', required: true },
{ name: 'content', type: 'editor' },
{ name: 'published', type: 'bool' }
]);
// Export all collections
export const MY_COLLECTIONS = [...DEFAULT_COLLECTIONS, postsCollection];
`
Then run npm run setup` to provision them automatically.
- Frontend: SvelteKit 2 + Svelte 5
- Backend: PocketBase
- Language: TypeScript
- Styling: CSS (scoped)
FStack aims to be the fastest way to start a full-stack project with:
1. Zero backend setup ā PocketBase is a single executable
2. Type-safe by default ā Full TypeScript support
3. Batteries included ā Auth, database, realtime, files all ready
4. Test-first confidence ā Built-in integration test suite
---
Built with ā¤ļø using SvelteKit + PocketBase