return to table of content

Pocketbase: Open-source back end in one file

brabel
9 replies
7h27m

It seems to me that redbean is a much simpler, vastly lighter one-file web server + sqlite DB: https://redbean.dev/

As a bonus, the same file runs on basically any OS without any dependencies on the local system, not even libc.

TeddyDD
5 replies
6h11m

It's like saying nginx is better than superbase/firebase. Apples to oranges.

You could replicate PocketBase in Readbean, but you would have to implement from scratch: - resources with CRUD API and real time subscriptions - admin UI - authz & authn system

brabel
2 replies
5h6m

I didn't say it's better. Why are people always misinterperting what they read (it's like you've never had text interpretation classes at school, or logic lessons to undestand how to infer implications from logical statements correctly)? Please read again: I said it's vastly simpler (which may not be better for you!) and lighter (just measure it). The comparison is apt for me because the description "open-source backend in one file" matches both projects well and it's something I'm interested in, with readbean being far closer to my alley.

Philpax
1 replies
4h36m

Your initial comment presents Redbean as a comparable solution, which it's not; they serve very different use cases.

Redbean requires you to write server code; Pocketbase does not. Redbean does not offer a realtime database, authentication, an admin dashboard, integrated file storage, or an inbuilt API.

I like Redbean, but it's in a completely different "market sector". It's like comparing a kit car to a luxury car: yes, they both technically serve the same purpose, but one requires much less assembly and offers a much more usable experience out of the box.

brabel
0 replies
1h53m

They are comparable solutions to the problem "Open-source backend in one file". I don't care at all about "realtime database, authentication" and whatever, I care about what the title of the post says. For that purpose, Redbean is a nice alternative.

It's like comparing a kit car to a luxury car

If all I need is a bicycle, a kit car is already over the top but will do. A luxury car makes no sense. You're thinking like everyone has the same needs that you have or something.

yard2010
0 replies
4h29m

Fruits can be compared

testless
0 replies
5h53m

I think you meant supabase.com instead of superbase.com.

lars_francke
1 replies
6h51m

To me it seems as if both tools serve a pretty different purpose.

Redbean doesn't have authentication or the client SDKs at least.

brabel
0 replies
6h31m

The self-described purpose is "opensource backend in one file". They both offer that.

keb_
0 replies
6h24m

I love redbean, just holding out for ARM support.

082349872349872
8 replies
7h9m

What minimal front-ends are there that one could combine with this minimal back-end to provide a minimal end-to-end?

BilalBudhani
6 replies
6h51m

I would say

- htmx (https://htmx.org/)

- Alpine.js (https://alpinejs.dev/)

both are minimal and very easy to get started.

flaviocopes
4 replies
5h31m

Been enjoying using PocketBase with Astro + htmx + Alpine

BilalBudhani
3 replies
3h36m

nice! I'm curious to know why would you need Alpine or Htmx if you have one of them in your app? I thought they are mutually exclusive.

flaviocopes
1 replies
3h29m

htmx = client-server networking Alpine = JS sprinkles

Alpine is for example, I want to show/hide a menu on mobile. I want to upload files via drag and drop. I want to have a bin icon over an image when I hover with mouse to delete it. I want to double click an input field to edit it. I want to close an overlay when I click outside of it, or when I press “esc”.

Also modals, although you can do them in htmx very nicely too, so that’s borderline.

Anything that involves network, htmx. Things that are just frontend, Alpine suits better.

_hyperscript is basically the Alpine equivalent.

It's like the difference between Turbo and Stimulus in the Rails world

BilalBudhani
0 replies
3h23m

Gotcha! I'm gonna dig more into this stack. Thanks for breaking it down for me.

recursivedoubts
0 replies
2h12m

we go into detail on this in the client side scripting chapter of our book:

https://hypermedia.systems/client-side-scripting/

synergy20
0 replies
3h31m

are you using one of them or both? I'm using htmx and not sure if I really need alpine.js yet.

kekub
0 replies
5h14m

Depends on what you consider minimal, but I enjoy working with PocketBase and VanJS[1]. However there is no component library built in (if this is what you were asking for).

[1]: https://vanjs.org/

rijavecb
7 replies
5h44m

Pocketbase is amazing! So far I had a great experience using it as a backend/database for the app I'm building where I'm using React with Vite for the frontend. I'm using it mainly for auth and for keeping track of paid and free accounts. Some things that I found rather useful:

- It's super easy to host. I was initially thinking of using Appwrite or Supabase but found it a tricky to self-host them, especially Supabase. I could spin up Appwrite quickly via CapRover, but found it an overkill for what I needed.

- View collections [1] make it easy to return just a subset of the data that you need. In my case I'm using a view collection as a join for users and paid_users collections, where I just return their paid through date.

- The fact that you can extend it with Go or JS [2] should make it possible to completely skip having a backend, at least if your needs aren't very complex.

I definitely plan to continue using it for some smaller/side projects. Currently I'm thinking of trying to use it as CMS for an Astro blog and in the future as backend for some browser extensions.

[1] - https://pocketbase.io/docs/collections/#view-collection

[2] - https://pocketbase.io/docs/use-as-framework/

Daynil
6 replies
3h39m

I feel like super easy to host needs to be re-emphasized. We're talking about dropping a single binary into your server and you're off to the races. If only more things were so simple.

tronikel
2 replies
2h50m

Didnt docker make this easy for all projects?

serf
0 replies
16m

the +docker step already adds friction, so I can see the point.

noodlesUK
0 replies
2h48m

Not really because then projects started needing multiple containers and orchestration, and might be fussy about the order the different services come up.

imnotreallynew
1 replies
3h35m

Isn’t that how any Go project is put online?

paulgb
0 replies
1h58m

The key distinction here seems to be that it uses an in-core database (SQLite), whereas a Go project may depend on an out-of-core database like Postgres, which would then also have to be deployed.

For many projects (especially hobby projects where downtime is tolerable), the former is probably quite sufficient.

pixelatedindex
0 replies
2h11m

Is that the same concept that Deno uses?

WM6v
6 replies
6h44m

What are realistic bottlenecks to expect from a backend like this? Eg. a web app serving users that write posts simultaneously

blackoil
5 replies
6h38m

More than one server. Sqlite should be thread safe and simple services can scale to thousands of parallal users. If you are OK with some downtime every 6 months when server goes down it will scale well. Deploy/ rollback will be an effort.

ozim
3 replies
6h19m

Downside with separate SQLite databases will be when you want to have statistics over many users.

rudasn
1 replies
5h47m

I'm in this situation right now. How would one go about solving this?

To keep this simple, I'm thinking exporting just the necessary data from each db and inserting that to a stats db (having a source column to each table, referring to the original db). Then load the stats db with Metabase or something.

Migrations on the stats db may be a bit of a pain, as well as making sure that all data is exported and imported correctly every time.

I'm sure there are better ideas.

jocaal
0 replies
5h37m

Litestream is a library that allows you to easily create backups. You can probably just do analytics queries on the backup data.

https://litestream.io/

djfobbz
0 replies
1h48m
WM6v
0 replies
5h36m

Gotcha. And that makes sense for the purpose of the project. Should one have multiple instances of sqlite dbs, what strategies exist to keep them synced?

BilalBudhani
5 replies
9h22m

I have been following PocketBase since its early day - what I absolutely love about this project is how it actively tries to avoid complexity and focuses on simple yet minimalist approach. Moreover, the ease of deployment by simply uploading a single binary on the server makes it even more attractive.

After they introduced Javascript support in the backend - I feel it became a serious contender to challenge Remix, Next.js etc. frameworks.

Looking forward to v1

d1sxeyes
3 replies
9h14m

I use PocketBase for mostly everything where I need a back end now. I came across a situation where I needed to write a custom SQL join (technically I could have just fetched all the data and done it in Node, I suppose).

I was shocked at how easy it was to write the query even inserting URL parameters and selecting based on the authenticated user only.

Fully recommend for basically everything. Great app. Not sure it would replace Next or Remix, but definitely add to the stack to simplify.

BilalBudhani
2 replies
9h6m

Interesting! I haven't made anything serious yet with the PocketBase (mostly due to lack of time & not anything to do with PB).

I'm curious to know what kind of projects did you build using PB and how was your development experience?

ilrwbwrkhv
0 replies
2h7m

One of my production projects with around 20,000 customers and 400k arr runs on Pocketbase with zero issues. I cannot recommend it enough.

d1sxeyes
0 replies
6h25m

Bits and pieces. A bedtime tracking app for my kid, a microblog, a TikTok clone, a budget app, a text-to-speech app with translation functionality…

Development experience was outstanding. I primarily use SvelteKit and integrate PocketBase for SSR, so I use the SDK almost exclusively and it’s fantastic. Everything just works exactly the way you would expect.

I can’t imagine anything easier to implement, and as yet, I haven’t found any major gaps in what I can do with it, normally with OOB functionality.

Development velocity is very high and the developer is super responsive on GitHub. The documentation is very good and kept up to date pretty well.

My only real concern is that the project has a pretty poor bus factor, otherwise, I’m very impressed.

harha_
0 replies
8h16m

it actively tries to avoid complexity

Sounds refreshing.

saasjosh
3 replies
6h24m

Cool homepage but I don't even understand what this thing does.

addandsubtract
1 replies
4h22m

It's like a smaller Supabase, which was an open source alternative of Firebase. So basically a database, authentication, file storage, and backend in one solution.

ilrwbwrkhv
0 replies
2h2m

It's substantially better than Supabase and much easier to host and deploy.

diggan
0 replies
6h21m

Are you a developer? Because it seems to be geared towards developers. It's something like a all-in-one backend that you can use as a starting point and extend if needed.

Personally, I think the website is clear and concise. Doesn't even have any marketing filler which is a huge plus in my corner.

remram
3 replies
3h0m

I am a bit confused, is it the backend's backend? E.g. something that is used by the HTTP server app, like a DBMS would be?

Or is it actually the backend, e.g. the frontend (browser) talks to it directly?

ilrwbwrkhv
1 replies
2h5m

You would use it instead of things like Supabase and Appwrite. It gives you a server, a db and easy authentication, authorization with real-time queries like firebase.

remram
0 replies
1h31m

Maybe it's not for me, I really don't know what that means. If it only describes itself as "a replacement for <name>" I feel like I'm not the target at all.

kisamoto
0 replies
2h53m

It can be the backend itself if you just need auth (both authentication and authorization) and your SQL tables to be a REST API. This often suits frontend single page applications in JS/TS and Pocketbase also provides a JS SDK to ease this (with realtime updates). It's a similar model to Firebase but without the lock-in.

However if you want to write more logic you can also import Pocketbase as a library and extend it with hooks, custom endpoints etc. all written in Go.

Edit: Added more info about using Pocketbase with a JS SPA frontend.

doublerabbit
3 replies
6h22m

Scouring the documentation there's mention of a way to use PocketBase without JavaScript or Dart. Are they the only methods?

diggan
1 replies
6h20m

It seems to be Golang based from what I can tell? And I'm guessing it either exposes a HTTP or WebSocket API, both which are usable from any language.

skottenborg
0 replies
6h10m

This is correct. It's golang and it exposes a plentiful API.

eitland
0 replies
5h36m

TypeScript is support on the frontend for oldtimers like me who have used plain JS for far too long and refuse to accept the torture of unnecessarily untyped languages any longer.

Also as already mentioned by others there exist web APIs.

rolisz
2 replies
7h14m

I mostly know Python. Is there something similar in Python? Or the backend language is not relevant, because you mostly use this from JavaScript anyway?

eternityforest
0 replies
6h36m

Packaging this as a Python lib that could run under WSGI/ASGI and use all the awesome python libs would be amazing. I wonder if that's possible?

ajayvk
0 replies
4h47m

I have been building a project https://github.com/claceio/clace which aims to make building hypermedia based web applications easier. Clace is implemented in go, it uses Starlark (python syntax subset) for application configuration. With Clace, the apps are implemented using Starlark and (go) html templates, HTMX is used for web interface, app developer does not need to write any JavaScript.

notyoutube
2 replies
5h18m

I've skimmed at the docs, and it's not clear to me how it would deal with:

* Something like row-level access control, so that people can only access the data in tables that belong to them (say clients can only view their own purchases, and also not modify them after they checked them out).

* Integration with the rest of the world, e.g. sending email, acting on triggers, etc.

* Something like CSV export/import.

* Internationalization.

Would that all be possible? Straightforward? Do those all require extending (with go or js)?

Looks like a nice tool.

jddj
0 replies
5h6m

The first point (authn) is inherent to the unextended framework via filter rules.

Most of the remainder requires extension other than authz emails, but extension at its simplest just means adding a plain old JavaScript function to run on a record lifecycle event of some kind - typically [before/after] [insert/update/delete] of <record>. Various GO APIs are exposed to the JavaScript runtime for doing filesystem, cryptography, http, email, etc work.

For i18n you have templates and a database.

flaviocopes
0 replies
5h8m

Check out

API Rules https://pocketbase.io/docs/api-rules-and-filters/#api-rules

Hooks https://pocketbase.io/docs/js-overview/

Admin panel has backups for data, and import/export of collections schema

jddj
2 replies
6h7m

I've been using Pocketbase in production for a few months now, with alpinejs on the front end.

The development philosophy is on point. It's genuinely pleasant, pragmatic software which serves a real purpose and it improves weekly without feature creep.

I watch the discussions and issues slowly getting more tiresome as it becomes more mainstream and worry that he'll burn out trying to keep up with the level of support he's offered until now.

I would very strongly encourage anyone using this to generate income to support the project on open collective.

jslakro
1 replies
4h23m

What other technologies in the stack you have?

jddj
0 replies
3h12m

There are two C# services which do some background bits and pieces.

This logic could have been put within pocketbase as well, but the body of work they depend on was already .net.

Other than that it's just little JavaScript callbacks in the back and typescript in the front.

There isn't much missing that you truly need to bolt things on for, provided SQLite is appropriate for your usecase.

zffr
1 replies
2h41m

What are the pros/cons of this over firebase?

victorbjorklund
0 replies
28m

Pro: - It will be cheaper when scale - You have full control of the data since selfhosted - Easier to extend with custom code

Cons: - you need to take care of all the hosting, backups, etc - cant scale to infinity like firebase (but on the other hand when you reach that scale youe firebase bill will be huge anyway)

punnerud
1 replies
5h0m

Seems like a JavaScript based version similar to Django (Python)?

robjan
0 replies
3h52m

It's more a self-hosted alternative to Firebase written in golang

karencarits
1 replies
6h12m

It is great to see the number of good opensource projects in this area. Grist and NocoDB deserve mentions, although more targeted towards database management. It is also amazing that they provide so simple ways to get started (single file/electron)

- https://github.com/gristlabs

- https://nocodb.com/

slig
0 replies
4h42m

Did not know about either of those, thanks. I've been using Baserow for small projects that I believe Pocketbase is a way better fit.

fullstackchris
1 replies
2h45m

Very cool. Reminds me of the encore framework, also written in go: https://github.com/encoredev/encore

Need to spend some more time looking into these go based frameworks, they seem great for quick prototyping

ilrwbwrkhv
0 replies
2h3m

Nope encore is horrible to use in comparison. Pocketbase is levels above encore and similar projects.

TruthWillHurt
1 replies
5h2m

Very cool, but this is a security anti-pattern.

Having the auth, db and file server in the same service.. an attacker doesn't even need lateral traversal or privilege escalation once inside..

deberon
0 replies
4h4m

There’s something to be said about drastically reducing your threat surface too. Locking down 1 server is easier than locking down a fleet. You can still have security in depth inside your server.

Ilasky
1 replies
6h23m

Been using Pocketbase for almost all of my projects lately. Its realtime database is especially nice to introduce multiplayer functionality with relative ease.

It plus SvelteKit has been a dream to get up and running using the JS SDK.

overbytecode
0 replies
2h7m

I’m curious how you’re integrating it with Sveltekit? Are you using Sveltekit just as a static generator?

xsumirx
0 replies
5h51m

Didn't know tool like this existed. Thanks for sharing.

twsted
0 replies
4h56m

Pocketbase seems really well done and useful.

I am building something similar but at a lower level and based on PostgreSQL.

https://github.com/sted/smoothdb

It aims to be compatible with the PostgREST API.

thangngoc89
0 replies
7h46m

I've been using Pocketbase for several projects. While it's a delightful experience for solo-dev to quickly finish a project from backend to complicated frontend, I wish it has bulk-insert out of the box.

tamimio
0 replies
1h34m

I like this for testing and quick/simple database, very useful in concept for building a platform for embedded work, where you don’t need to go down the rabbit hole in the whole full stack tech.

sonovice
0 replies
8h37m

Have been using pocketbase in production for a mobile app for a couple of month now and so far it was a _very_ pleasent experience. Together with the JS SDK it is now my go to backend framework for everything where I don't need specialized libraries (like ML stuff etc.)

rbosinger
0 replies
41m

I've been using Pocketbase for personal projects on the machine I use to self-host services. It's great. You get CRUD and real-time stuff for free and I didn't really have to spend much time learning to start working with it and having it running in an LXC.

oschvr
0 replies
9h20m

Really cool, I'll give it a try

melicerte
0 replies
1h55m

I was looking for a frontend I could use out of the box on top of a sqlite database to design and store my wine collection (since I removed Vivino and its 800+ "partners" it shares my data with).

Looks like a single executable, the admin interface and the database I can store on my laptop (and add it to my backup) is all I was looking for. Thank you for PocketBase and thank you for sharing it.

That's why I always come back to HN :-)

jadayesnaamsi
0 replies
1h48m

It is the first time I see that "hook" pattern in a Go API backend: `hook.Hook` and `hook.TaggedHook`.

Where does it come from?

Why is it useful here?

What are the alternatives? Advantages/Drawbacks?

Is there an article somewhere, outside of the Pocketbase docs, presenting that pattern?

- https://github.com/pocketbase/pocketbase/blob/master/core/ap...

- https://github.com/pocketbase/pocketbase/tree/master/tools/h...

ilrwbwrkhv
0 replies
2h10m

Out of all the PaaS I tried including Supabase and Appwrite, Pocketbase is the best. Great performance, intuitive features, actually self hosted and a joy to deploy.

igtztorrero
0 replies
3h34m

Good Golang anda Svelte code organization, I Will take as example

eternityforest
0 replies
6h37m

Looks like what you hope LibreOffice Base will be, when one first years of the existence of those kinds of tools.

Really nice, looks like something I'd love to work with someday!

chazeon
0 replies
3h0m

I feel like this will be super interesting when pairing with static site generator such as eleventy. Using static site generator is sometimes difficult because of lacking a web backend and ghost is too heavy for me.

bambax
0 replies
6h6m

First time I hear about this... looks absolutely fantastic! Will try.

air7
0 replies
1h50m

this is great. What would be the frontend equivalent? A simple, no bells and whistles frontend to throw something together quickly?

account-5
0 replies
6h50m

Dart SDK, excellent. Just what I'm looking for.