Search
⌃K

Expose PocketBase backend

This tutorial will explain how to expose a localhost PocketBase backend and give it a shareable link that is accessible from the internet.

PocketBase

Open Source backend for your next SaaS and Mobile app in 1 file, consisting of embedded database (SQLite) with realtime subscriptions, built-in users management, convenient dashboard UI and simple REST-ish API.
Explore the documentation to see all the features and capabilities of PocketBase.

Prerequisites

Step 1 - Start PocketBase service

./pocketbase serve
# > Server started at: http://localhost:8090
# - REST API: http://localhost:8090/api/
# - Admin UI: http://localhost:8090/_/

Step 2 - Create admin account

Navigate to http://localhost:8090/_/ and fill the required fields.
Create admin account

Step 3 - Create a collection with some records (optional)

Create collection for example post collection:
Create collection
Add some posts:
Add posts

Step 4 - API access

Grant access to API list action:
Grant to List action
Confirm API access via localhost:
curl http://localhost:8090/api/collections/posts/records
JSON result (example):
{
"page": 1,
"perPage": 30,
"totalItems": 2,
"items": [{
"@collectionId": "WvcPifBVEqtFagS",
"@collectionName": "posts",
"created": "2022-07-29 03:03:09.326",
"id": "uh6ON17M1PQvM7b",
"post": "lorem ipsum dolor ... bibendum ... donec suscipit.",
"slug": "hello-world",
"title": "Hello world",
"updated": "2022-07-29 03:03:09.326"
}, {
"@collectionId": "WvcPifBVEqtFagS",
"@collectionName": "posts",
"created": "2022-07-29 03:03:55.468",
"id": "lk4Zp5nvuStwRzJ",
"post": "lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi bibendum commodo congue. vivamus efficitur aliquam felis, id viverra eros blandit sit amet. nam feugiat purus ac sem aliquam, sit amet dictum dui bibendum. sed tincidunt porttitor odio at feugiat. cras sed viverra libero. suspendisse potenti. nulla eu ullamcorper quam, in tempus nulla. quisque accumsan euismod finibus.\r\n",
"slug": "testing-1-2-3",
"title": "Testing 1 2 3",
"updated": "2022-07-29 03:04:02.263"
}]
}

Step 5 - Access PocketBase API from the internet

Create HTTP tunnel and forward the traffic to local PocketBase address.
loclx tunnel http --to localhost:8090
which results:
HTTP Tunnel
Test API access via loclx.io sub-domain:
API access
You can also utilize the PocketBase Javascript SDK (pocketbase/js-sdk) to consume the API.