Quick overview of a ready-to-use backend for your frontend projects
Published on: 2024-10-12
Written by: Théo Tchilinguirian
You can also read this article on Medium.
So you need to make a frontend but don’t have the time to develop a backend application? PocketBase might be the solution you’re looking for! It’s a free and open source frontend-agnostic backend written in Go. You can set it up in minutes and focus entirely on your frontend.
In this article, we’ll cover:
For more details, check out the official PocketBase documentation. It’s concise, clear, and simple - a big plus for this product!
PocketBase is extremely easy to install. Here’s how:
pocketbase
.Let’s get started using PocketBase! For this example, we’ll make a simple blog app frontend in TypeScript with Angular and use the JavaScript SDK.
Run the PocketBase server using the following commands. You should see this:
$ cd backend
$ ./pocketbase serve
2024/10/12 18:02:32 Server started at http://127.0.0.1:8090
├─ REST API: http://127.0.0.1:8090/api/
└─ Admin UI: http://127.0.0.1:8090/_/
Visit the Admin UI URL at http://127.0.0.1:8090/_/
to create your admin account. Through this UI, you can:
All database files and configurations are stored in the same directory as your pocketbase
executable.
PocketBase offers official SDKs for Dart and JavaScript/TypeScript. While you can interact with the API without an SDK, using one simplifies the process. Here’s an example of how to authenticate a user using the JavaScript SDK:
import PocketBase from 'pocketbase';
const pb = new PocketBase('https://pocketbase.io');
...
const authData = await pb.collection('users').authWithPassword('YOUR_USERNAME_OR_EMAIL', '1234567890');
// After authenticating, you can access the auth data from the authStore
console.log(pb.authStore.isValid);
console.log(pb.authStore.token);
console.log(pb.authStore.model.id);
// "Logout" the last authenticated model
pb.authStore.clear();
PocketBase’s API is a standard REST API. For more information, refer to the official API documentation.
PocketBase handles:
Everything is easy to configure through the UI, and you can access documentation directly within it.
PocketBase (and similar Backend-as-a-Service solutions) is excellent for basic needs and prototyping. However, it’s not always the best choice. Here are some considerations:
I used PocketBase for a graded project during my training, where I created a working frontend in Angular with TypeScript. Thanks to PocketBase, I was able to focus entirely on frontend development without worrying about backend complexities.
That said, remember to configure your backend properly, especially the API rules. For production-ready apps, put your security skills to use and carefully evaluate whether a BaaS is suitable for your project.
PocketBase’s simplicity and features make it an excellent choice for quick and easy backend development. For more details, visit the official documentation.