jm61 / pocketbase-sveltekit-starter

this is a starter template for sk and pb with go backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PocketBase / SvelteKit Demo App

A starter-kit showing how to use customized PocketBase as a backend to SvelteKit frontend. This is a high-performance frontend+backend combination since frontend is static and backend is a single compiled Golang binary (JAMstack).

  • SvelteKit frontend is fully static, client-side only so that here is no need for NodeJS at runtime. It is generated using adapter-static
  • PocketBase provides complete (and fast) backend including:
    • databse (SQLite)
    • CRUD API for database
    • realtime subscriptions for LIVE data (server push to browser)
    • Authentication and Authorization (email + social login)
    • file storage (local filesystem or S3)
  • PocketBase can be downloaded as binary. But if you want to extend it with custom Golang code then code is included to compile it locally with extensions such as custom endpoints (e.g. /api/hello) and database event hooks (e.g. executing Go handler functions when a database row is created)

Setup

Follow these step EXACTLY, or else it won't work.

  1. Follow ./backend/README.md
  2. Follow ./frontend/README.md

Developing

After you've done the setup in the above two README files, run the backend and the frontend in dev mode.

npm run backend:dev
npm run dev

Now making changes in the Svelte code (frontend) or Go code (backend) will show results (almost) immediately.

Building

To create a production version of your app:

npm run build

The above creates backend/pocketbase (customized version) and client-app in frontend/build.

Now not only can you serve this app with npm run preview but much better ... you can serve it statically using PocketBase using --publicDir ../frontend/build option So now just visting http://127.0.0.1:8090/ will serve your SvelteKit frontend along with your PocketBase backend - a single binary serving frontend, backend, API, auth, uploaded files, etc.

Configurable Hooks

Please read about the "hooks" system in ./backend/README.md It is a very easy and powerful way to extend your application with minimal configuration and perhaps no code.

Feedback

Please provide feedback by opening an issue or starting a discussion.

About

this is a starter template for sk and pb with go backend


Languages

Language:Go 41.5%Language:Svelte 39.4%Language:TypeScript 12.5%Language:JavaScript 2.0%Language:Shell 1.9%Language:Dockerfile 1.6%Language:HTML 1.1%