Pocketbase vs. Supabase: An in-depth comparison (Auth, DX, etc.)

3 Comments
Published: 05.02.2023

Are you looking for a new Backend-as-a-Service for your next side project? Look no further! In this blog post, we will compare two popular solutions, Pocketbase and Supabase. We will dive into the differences in terms of Auth, Configuration, DX, and more. By the end of this comparison, you will have an overview of both services, and you can decide what’s best for your needs. So, buckle up, and let’s compare Pocketbase vs. Supabase!

Introduction

When it comes to developing a side project, choosing a BaaS solution can save you hours of time. Two of the most popular BaaS solutions are Pocketbase and Supabase.

Pocketbase is a single binary you can download and execute. As a data storage, it uses a simple SQLite database. On the other hand, Supabase consists of multiple microservices, with a PostgreSQL database as data storage. This allows the use of all features and plugins provided by PostgreSQL. Supabase is an open-source SaaS solution, meaning you can use their free or paid tier but also host it yourself.

Both support most features needed for simple side projects, such as authentication, API, and real-time updates. Whether you prefer a simpler setup or a more complex and feature-rich solution, either of these options can meet your needs.

So let’s compare Pocketbase vs. Supabase and find your favorite!

Efforts to start a first project

When it comes to starting a new project, both Pocketbase and Supabase offer different levels of ease and effort.

Need help or want to share feedback? Join my discord community!

Starting a project with Supabase is really easy, thanks to the two free projects that are available. All you need to do is sign up, create a project, and you’re ready to go.

On the other hand, Pocketbase requires a bit more setup. To get started, you need to download the binary from Github, start it, and set up SMTP to send emails (you can learn how to do that here). While this process may take a bit longer, it is still relatively straightforward, and once it is set up, you will have a powerful backend solution at your disposal.

KOFI Logo

If this guide is helpful to you and you like what I do, please support me with a coffee!

To learn how to set it up, check out my blog post for Pocketbase and Supabase.

Authentication

When it comes to setting up authentication for your project, both Pocketbase and Supabase offer a similar level of ease and functionality.

They both provide different SDKs, such as Javascript/Typescript, which make the authentication process really easy. They support multiple authentication methods such as email-password, google, and more. The setup process is straightforward, and you’ll be able to get up and running in no time.

The code snippet shows how to register and log in as a user with Pocketbase and Supabase.

//// Pocketbase
// Register 
await pocketbase.collection("users").create({
  email,
  password,
  passwordConfirm: password,
});

await pocketbase.collection("users").requestVerification(email);

// Login
await pocketbase.collection("users").authWithPassword(email, password);

//// Supabase
// Register
const { data, error } = await supabase.auth.signUp({
    email,
    password,
});

// Login
const { data, error } = await supabase.auth.signInWithPassword({
    email,
    password,
});

Configuration

Securing your data with authentication rules is a lot of manual work in both solutions. In my opinion, the RLS language of supabase is a bit easier to understand than the one of Pocketbase, but after trying around a bit, it is simple as well.

Real-time

In this section, we will be comparing the real-time capabilities of Pocketbase and Supabase. Regarding real-time updates, Pocketbase offers a straightforward and simple solution. Instead, Supabase’s channel model is more complex and less intuitive.

The following snippet shows both the supabase and pocketbase implementations. Here it is to say that it only shows the most basic version that is also fairly simple with supabase:

// Pocketbase
pocketbase.collection('chats').subscribe('*', async (e) => {
    allChats = await getChatWithUsers();
});

// Supabase
chatsWatcher = supabase.channel('custom-all-channel')
.on(
    'postgres_changes',
    { event: '*', schema: 'public', table: 'chats' },
    async () => {
        ({ data: allChats } = await getAllChats());
    }
)
.subscribe()

TypeScript support

Comparing typescript support in 01.2023, Pocketbase was performing better. The concept of Supabase injecting types into the client is a really good idea, but when merging tables together, it creates an x | x[] type, which adds unnecessary complexity (you have to manually check if it is an array or not even though it is always an array). If this changed in the latest updates please leave a comment, so I can update it here 🙂.

Pocketbase’s TypeScript implementation is way simpler but gets the job done as expected.

Self-host

Regarding self-hosting, Pocketbase is a straightforward option, as you simply need to move the binary to a server and execute it. On the other hand, setting up Supabase as a self-hosted solution requires setting up multiple microservices with the aid of Docker.

Conclusion and overall opinion

In conclusion, Pocketbase and Supabase are great options for a backend for your next side project. While both have their own advantages, I personally prefer Pocketbase due to its simplicity in setup and also the query language (but that is completely personal preference. Thus, it was not mentioned in detail). It is suitable for most side projects, and in case additional scaling is required, you can first increase the resources and then look for alternative solutions (I guess most of our projects will never reach that stage anyway^^). Here is a little summary of all the points discussed before:

FeaturePocketbaseSupabase
Efforts to start a projectDownload and execute binaryOne click, with two free projects
AuthenticationMultiple auth methods and SDKsMultiple auth methods and SDKs
ConfigurationA lot of manual labor, a bit hard to understand at firstA lot of manual labor
TypeScriptSimple implementationInjects types into the client but creates unnecessary arrays on merges
Real-timeSimpleChannel model is not very intuitive
Self-hostingSimpleSimple, but requires setting up multiple microservices
Overall OpinionPreferred due to simplicityGood option, but less preferred

Thank you for taking the time to read about my comparison of Pocketbase vs. Supabase. I hope you found it informative and helpful. If you have any feedback or questions, contact me via the chat on the right, or email me at mail@programonaut.com. If you want to stay updated on my latest content, don’t hesitate to subscribe to my monthly newsletter. I’m excited to continue sharing my thoughts and insights with you.

Discussion (3)

Add Comment

Your email address will not be published. Required fields are marked *