Published on
What are the Firebase alternatives with a relational database?
The main Firebase alternatives with a relational database are Supabase, the closest match because it combines PostgreSQL, authentication, realtime, and a São Paulo region; Appwrite Cloud; Neon, a serverless PostgreSQL with managed authentication; PocketBase, which is self-hosted and uses SQLite; and your own backend in Node.js or Python with a managed PostgreSQL, such as Zenifra’s, billed in Brazilian reais. The choice depends on what you want to keep getting out of the box: if you want the BaaS experience, Supabase fits best, and if you want SQL without lock-in, prices in reais, and infrastructure in Brazil, you build your own API and use Firebase Authentication or an authentication library.
Why switch from Firestore to a relational database
Firestore is a NoSQL document database. Its data model documentation says that, unlike a SQL database, there are no tables or rows: data lives in documents organized into collections, and the database is schemaless, so each document in a collection can have different fields and types. That speeds up the start of an app, but it hands the job of keeping data consistent to your code. In a relational database such as PostgreSQL, the schema, foreign keys, UNIQUE and CHECK constraints, and column types are enforced by the database itself.
The second reason is queries. In the Standard edition, which most apps use, Firestore only runs Core operations: reads, writes, and basic queries. Indexes are required, compound queries depend on manually configured composite indexes, OR queries are limited to 30 disjunctions, and not-in accepts up to 10 values. Joins with subqueries exist in Pipeline operations, but those operations belong to the Enterprise edition. In PostgreSQL, a JOIN across orders, customers, and products, a GROUP BY per month, or a subquery is standard SQL, on any plan.
The third is reporting. The official path for analyzing Firestore data is exporting it to BigQuery, and the export documentation explains how to load the data there. With a relational database, the report runs directly on the application database or on a replica, in SQL, and tools such as Metabase connect without an intermediate export.
It is fair to point out two things. Transactions are not a reason to switch: Firestore’s documentation advertises ACID transaction support and atomic batch operations. And Firestore has advantages a custom backend does not give you for free, such as realtime listeners, offline caching in the mobile and web SDKs, and scaling without managing servers. The switch pays off when queries, integrity, and reporting start costing more development time than those advantages save.
What reading data costs on Firestore
Firestore charges per operation. According to the Standard edition pricing page, read on November 6, 2026, each database has a free daily quota of 50,000 reads, 20,000 writes, 20,000 deletes, and 1 GiB stored, plus 10 GiB of outbound data per month, and only one free database per project. Above the quota, in the São Paulo region (southamerica-east1), reads cost US$0.045 per 100,000 documents, writes US$0.135 per 100,000, and storage US$0.135 per GiB per month. In Iowa (us-central1), reads cost US$0.03 per 100,000.
The detail that matters is what counts as a read. The billing documentation says you pay for the documents and index entries read to satisfy a query, and that a realtime listener charges one read each time a document in the result set is added or updated. A list screen that reads 500 documents and is opened 2,000 times a day generates 1 million reads per day. Aggregation queries, such as count(), sum(), and avg(), are cheaper: they charge one read per 1,000 index entries, with a minimum of one read.
The table shows reads only, over 30 days, after the free daily quota. Writes, storage, and outbound data come on top.
| Reads per day | Billed reads in 30 days | São Paulo (southamerica-east1) | Iowa (us-central1) |
|---|---|---|---|
| 100,000 | 1.5 million | US$0.675 | US$0.45 |
| 1 million | 28.5 million | US$12.825 | US$8.55 |
| 10 million | 298.5 million | US$134.325 | US$89.55 |
An honest reading of the table: for a small app, Firestore is cheap, and at 100,000 reads per day the bill stays below US$1 per month. The cost grows linearly with usage, and that is where a relational database changes the logic: the price of a managed PostgreSQL is the plan price, not the number of rows read, and the limit becomes CPU, memory, and connections. The pricing page also notes that if you pay in a currency other than US dollars, the Google Cloud SKU prices in your currency apply.
Firebase alternatives side by side
The table compares the options most often mentioned by people leaving Firestore for a relational database. All data comes from each product’s official pricing, regions, and documentation pages, read on November 6, 2026. Firebase appears in the first row as a reference.
Pay attention to two columns. A region in Brazil matters for latency: a database in the United States adds a network round trip to every query. Currency matters for the budget: a US dollar price paid with an international card gets 3.5% IOF in Brazil and changes with the exchange rate every month.
| Option | Model | Authentication included? | Realtime? | Region in Brazil? | Currency | Starting price |
|---|---|---|---|---|---|---|
| Firebase (Firestore) | BaaS with a NoSQL document database | Yes, no cost up to 50,000 monthly active users | Yes, listeners | Yes, São Paulo (southamerica-east1) | US dollars on the pricing page | Free daily quota; then US$0.045 per 100,000 reads in São Paulo |
| Supabase | BaaS on PostgreSQL | Yes, 50,000 monthly active users on Free and 100,000 on Pro | Yes, Realtime with Postgres Changes | Yes, São Paulo (sa-east-1) | US dollars | Free US$0 (2 active projects, 500 MB database, paused after 1 week of inactivity); Pro from US$25/month |
| Appwrite Cloud | BaaS; TablesDB by default, PostgreSQL or MySQL on dedicated compute | Yes | Yes, Realtime API | No: Frankfurt, New York, Sydney, San Francisco, Singapore, and Toronto | US dollars, credit or debit card only | Free US$0 (2 projects); Pro US$25/month; dedicated database from US$10/month |
| Neon | Serverless PostgreSQL with backend services | Yes, Managed Better Auth | In beta | Yes, AWS São Paulo (aws-sa-east-1) | US dollars | Free US$0 (100 CU-hours/month and 1 GB per project); Launch US$0.106 per CU-hour + US$0.35 per GB-month |
| PocketBase | Open source backend in one executable, with embedded SQLite | Yes | Yes, realtime subscriptions | Wherever you host it | No paid license; you pay for the server | Free, self-hosted only |
| Your own backend + PostgreSQL on Zenifra | Your API (Node.js, Python, Go, Java, PHP) with managed PostgreSQL | No; you keep Firebase Authentication or use a backend library | Not as a service; WebSocket or SSE in your app, with Valkey pub/sub | Yes, infrastructure in Brazil | Brazilian reais, by PIX, boleto, or card, without IOF | App with a database from R$41.80/month; 5 GB of free Storage |
There is one option inside Firebase itself: SQL Connect, which the documentation describes as Firebase’s first relational database solution, with PostgreSQL managed by Cloud SQL, schema and queries in GraphQL, and integration with Firebase Authentication. According to the pricing page, it includes 250,000 operations per month at no cost and then US$0.90 per million operations, and the first Cloud SQL instance has a 3-month no-cost trial; if the project is not on the paid (Blaze) plan when the trial ends, the instance is archived. If you want SQL without leaving the Google ecosystem, it is the first place to look.
When each alternative fits best
Supabase is the most direct swap. It combines PostgreSQL, authentication, file storage, realtime, cron, and queues in one product, and it has a São Paulo region. If your app calls Firestore directly from the front end and you want to keep that style, with an SDK on the client and access rules in the database, it is the option that changes your architecture the least. The caveats are on the pricing page: the Free plan pauses projects after one week of inactivity and limits you to two active projects, and Pro starts at US$25 per month, billed in US dollars.
Appwrite Cloud suits people who want an open source BaaS with authentication, database, storage, functions, and realtime in one product, plus the option to self-host. The default database is TablesDB, and PostgreSQL or MySQL are available as dedicated compute, from US$10 per month per database. The official region list has none in South America, and the pricing FAQ says billing is by credit or debit card only. Neon is serverless PostgreSQL billed per CU-hour, with a São Paulo region and, on current plans, managed authentication (Managed Better Auth) that keeps users and sessions in your own database; it is a good base if you want PostgreSQL with branches per environment and do not need a full BaaS.
PocketBase is the simplest path for small and medium apps that fit on one server: a single executable with SQLite, authentication, files, and realtime. Its official FAQ is candid about the limits: the project offers no hosting, it scales only vertically, on a single server, and the documentation warns that before version 1.0 it is not recommended for production-critical applications. Note also that it is SQLite, not PostgreSQL.
Your own backend with a managed PostgreSQL gives you the most control and the most work. You write the API, decide how to authenticate, and expose only the endpoints the app needs, which replaces Security Rules with server-side authorization. In return, you get full SQL, any ORM or driver, and a fixed price per plan. On Zenifra, that comes with billing in Brazilian reais, infrastructure in Brazil, and the services a BaaS would give you ready-made, such as queues, cache, Scheduled Jobs, and file storage, in the same Console.
What you need to build if you leave the BaaS
Authentication is the first piece and the one that worries people most, but it does not need to change on day one. You can keep Firebase Authentication, which remains free up to 50,000 monthly active users, and validate the token in your backend with the Admin SDK verifyIdToken() method, which returns the user’s uid. If you also want to leave authentication, the firebase auth:export command exports accounts to JSON or CSV, but passwords come out hashed with the modified scrypt variant Firebase uses, so the new library must be able to verify that hash or users will need to reset their passwords.
Authorization moves. On Firebase, Security Rules decide who reads what directly from the client. With your own API, every query filters by the authenticated user on the server (for example, WHERE user_id = $1), and the front end never talks to the database. Cloud Storage files go to Storage (Armazém), Zenifra’s S3-compatible object storage: endpoint https://armazem.zenifra.com, region br-sp1, buckets that are always private, and signed links valid for up to 7 days. Storage is available to every organization and can be created in the Console.
Triggers and background tasks, which on Firebase are often Cloud Functions fired by writes, become a queue and a worker. Zenifra has two Queue engines: Valkey, with streams, consumer groups, and XACK, for simple tasks such as sending emails or processing webhooks, and RabbitMQ, with exchanges, routing keys, and native dead-lettering, for messaging between services. The worker is another project from the same repository with Private Exposure. Scheduled functions become Scheduled Jobs, with a cron expression in UTC, per-minute billing, and a 60-minute limit per execution.
Realtime and offline mode are the pieces you will miss most. On Zenifra, WebSocket and Server-Sent Events work over the project’s HTTP port, including on custom domains; with several instances, each connection stays on one instance, and the docs recommend a shared channel, such as Valkey Cache pub/sub, to notify every client. Firestore’s offline SDK cache has no ready-made equivalent: if your app depends on it, factor that in before migrating.
- Authentication: keep Firebase Authentication and validate with
verifyIdToken(), or migrate accounts withfirebase auth:export users.json --format=JSON. - Files: Cloud Storage to Storage (Armazém), S3-compatible.
- Triggers and tasks: Valkey Queue or RabbitMQ, with a private worker.
- Scheduled functions: Scheduled Jobs, cron in UTC.
- Realtime: WebSocket or SSE in the API, with Valkey Cache pub/sub across instances.
Recommended architecture for a typical app
Think of a common app built on Firebase: login, a dashboard with lists and filters, photo or document uploads, notification emails, and a daily report. On Zenifra, it becomes five pieces, each created in the Console and connected to the others by environment variables. Nothing is injected automatically: DATABASE_URL, the queue URL, and the Storage keys are copied from the Console and added to each project that uses the service.
The API is a public HTTP project, created from the GitHub repository, that receives the Firebase token (or the session from the new authentication), validates it, and queries PostgreSQL. For uploads, the API generates a signed Storage link and the browser sends the file straight there, without going through the server. When something has to happen later, such as generating a thumbnail or sending an email, the API publishes a message to the queue and responds right away, and the private worker consumes the message.
The daily report is a Scheduled Job that runs a SELECT with GROUP BY and stores the result, with no export to another system. The connection pool deserves attention from the start: DB-Starter accepts 15 connections, DB-Basic 72, and DB-Premium 147, adding up all API and worker instances. Above the limit, a new connection is refused with remaining connection slots are reserved.
- Web or mobile front end: calls the API over HTTPS and keeps using the Firebase Authentication SDK, if you keep the login.
- API: public HTTP project (Node.js, Python, Bun, Go, Java, or PHP), with a custom domain and HTTPS included.
- Managed PostgreSQL: versions 15 to 18, TLS with certificate validation, and automatic backups included in the plan.
- Queue: Valkey Queue for simple tasks or RabbitMQ for routing between services.
- Worker: another project from the same repository, Private Exposure, and the consumer command.
- Scheduled Job: reports, cleanup, and nightly routines, with cron in UTC.
- Storage (Armazém): uploads and files, with signed links.
How to migrate data from Firestore to PostgreSQL
Firebase has an official managed export and import service. With gcloud, gcloud firestore export gs://BUCKET --database="(default)" copies all documents to a Cloud Storage bucket, and --collection-ids limits the export to specific collection groups. The documentation includes three warnings that change your plan: the project must be on the Blaze plan, with billing enabled; the export charges one read per exported document, even though those reads do not show up in the usage dashboard; and the export is not an exact snapshot of the database at the start of the operation, because it may include changes made while it was running.
That export is great as a backup and is the official path to load data into BigQuery, but the files it produces were made for Firestore itself and for BigQuery, not for PostgreSQL. To move the data to a relational database, the simplest strategy is to read the collections with the Admin SDK, write each document as JSON into a staging table in PostgreSQL, and transform it with SQL. Run the managed export first, to have a safety copy, and use the script for the load. The script’s reads are also billed as normal reads: in São Paulo, 1 million documents cost US$0.45 above the day’s free quota.
The order that works is the same as any database migration: model the tables, run the full load in a rehearsal, validate the count per collection, and only then set the cutover window. On the day, freeze writes in the old app (for example, with a maintenance flag in the application itself), run the final load, and point the app at the new API. Cloud Storage files go to Storage (Armazém) with gcloud storage cp to download and the AWS CLI with the Storage endpoint to upload.
- Official backup:
gcloud firestore export gs://BUCKET --collection-ids=users,products,orders --database="(default)" - Files:
gcloud storage cp -r gs://FILES_BUCKET ./files - Upload to Storage:
aws --profile zenifra --endpoint-url https://armazem.zenifra.com --region br-sp1 s3 cp ./files s3://my-bucket --recursive - Validation:
SELECT collection, count(*) FROM staging_docs GROUP BY collection;compared with each collection’s count in Firestore.
Example schema and transformation
Consider an orders app with three Firestore collections: users/{uid} with name and email, products/{id} with name and price, and orders/{id} with a reference to the user, the date, and an items array with product, quantity, and price. In PostgreSQL, each collection becomes a table, the array becomes its own table, and the reference becomes a foreign key. The Firebase uid stays as the user key, which lets you keep Firebase Authentication without touching the data.
The script below, in Node.js with the Admin SDK and the pg driver, reads each collection and writes the documents into staging_docs. Before writing, it converts Timestamp to ISO text and DocumentReference to the document path, so the JSON is readable from SQL. For large collections, replace the full-collection get() with pages using orderBy and startAfter. With pg, the Console URI works as is.
After the load, the transformation is plain SQL: INSERT ... SELECT from the JSON, with jsonb_array_elements to unpack the items array. If an order points to a user that does not exist, the foreign key rejects the row, and that is the moment the migration reveals inconsistencies the schemaless model let through. Fix them at the source or handle them in SQL before the final load.
CREATE TABLE staging_docs (collection text NOT NULL, id text NOT NULL, data jsonb NOT NULL, PRIMARY KEY (collection, id));
CREATE TABLE users (id text PRIMARY KEY, email text UNIQUE NOT NULL, name text, created_at timestamptz NOT NULL);
CREATE TABLE products (id text PRIMARY KEY, name text NOT NULL, price_cents integer NOT NULL CHECK (price_cents >= 0));
CREATE TABLE orders (id text PRIMARY KEY, user_id text NOT NULL REFERENCES users(id), status text NOT NULL, created_at timestamptz NOT NULL);
CREATE TABLE order_items (order_id text NOT NULL REFERENCES orders(id) ON DELETE CASCADE, product_id text NOT NULL REFERENCES products(id), quantity integer NOT NULL CHECK (quantity > 0), unit_price_cents integer NOT NULL, PRIMARY KEY (order_id, product_id));
CREATE INDEX orders_user_created ON orders (user_id, created_at DESC);import { initializeApp, applicationDefault } from "firebase-admin/app"
import { getFirestore, Timestamp, DocumentReference } from "firebase-admin/firestore"
import pg from "pg"
const plain = v =>
v instanceof Timestamp ? v.toDate().toISOString()
: v instanceof DocumentReference ? v.path
: Array.isArray(v) ? v.map(plain)
: v && typeof v === "object" ? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, plain(x)]))
: v
initializeApp({ credential: applicationDefault() })
const db = getFirestore()
const client = new pg.Client({ connectionString: process.env.DATABASE_URL })
await client.connect()
for (const name of ["users", "products", "orders"]) {
const snap = await db.collection(name).get()
for (const doc of snap.docs) {
await client.query("INSERT INTO staging_docs VALUES ($1, $2, $3)", [name, doc.id, JSON.stringify(plain(doc.data()))])
}
}
await client.end()INSERT INTO users SELECT id, data->>'email', data->>'name', (data->>'createdAt')::timestamptz FROM staging_docs WHERE collection = 'users';
INSERT INTO orders SELECT id, split_part(data->>'user', '/', 2), data->>'status', (data->>'createdAt')::timestamptz FROM staging_docs WHERE collection = 'orders';
INSERT INTO order_items SELECT s.id, i->>'productId', (i->>'quantity')::int, (i->>'priceCents')::int FROM staging_docs s, jsonb_array_elements(s.data->'items') AS i WHERE s.collection = 'orders';The field names (createdAt, user, productId, priceCents) are from the example: replace them with your app’s. products loads with an INSERT ... SELECT like the one for users, before order_items.
Cost in reais of a PostgreSQL backend on Zenifra
The table builds the typical app from the architecture section with entry-level paid plans, based on Zenifra’s public price catalog read on November 6, 2026. All values are in Brazilian reais, with no currency exchange and no IOF, paid by PIX, boleto, or card. Authentication stays on Firebase Authentication, free up to 50,000 monthly active users, so it does not appear in the math.
To test before committing to a month, hourly billing charges only for running hours: the API on Basic costs R$0.05 per hour, PostgreSQL on DB-Starter R$0.018, and the queue on queue-starter R$0.08, and the first 5 GB of Storage are free. The worker and the Scheduled Job come in when the app needs them. Sign-up asks for a CPF or CNPJ, a mobile number, and an address in Brazil.
| Component | Zenifra plan | Monthly price |
|---|---|---|
| API | Basic (0.5 vCPU, 512 MB) | R$29.90 |
| Queue worker | Basic (0.5 vCPU, 512 MB), Private Exposure | R$29.90 |
| PostgreSQL | DB-Starter (0.3 vCPU, 256 MB, 15 connections) | R$11.90 |
| PostgreSQL disk | 5 GB at R$0.20 per GB | R$1.00 |
| Queue | Valkey Queue queue-starter (0.5 vCPU, 512 MiB, 5 GB) | R$44.90 |
| Daily report | job-starter Scheduled Job, 5 minutes per day (150 minutes at R$0.0001666666) | R$0.02 (R$0.02499999 exact) |
| Files | Storage with 20 GB stored (5 GB free and 15 GB at R$0.18 per GB-month) | R$2.70 |
| Total | R$120.32 (R$120.32499999 exact) |
Storage requests stay within the free monthly allowance of 50,000 writes and listings and 500,000 reads; above that, they cost R$0.40 per 10,000 writes and R$0.30 per 100,000 reads. When the app grows, the next database step is DB-Basic (1 vCPU, 1 GB, 72 connections) for R$49.90, and the next API step is Premium (1 vCPU, 1 GB) for R$62.90, with metrics and health checks.
This does not mean Firestore is more expensive in every case: with few reads it costs less than US$1 per month, as the reads table shows. The difference is predictability: on Zenifra the database price does not change with the number of reads, and a heavy report costs CPU, not a per-document charge.
Does Firestore support joins?
Not in the Standard edition: it only runs Core operations, which are reads, writes, and queries over one collection or a collection group. Firestore’s documentation lists joins with subqueries under Pipeline operations, which are part of the Enterprise edition, together with a more advanced query engine and optional indexes.
In practice, Standard edition users handle relationships by duplicating data across documents or running several queries on the client, and every document read is billed. In a relational database such as PostgreSQL, JOIN is part of standard SQL and has no per-row read charge.
Can I keep Firebase Authentication and only change the database?
Yes, and it is usually the safest path. The app keeps signing in with the Firebase SDK, sends the ID token to your API, and the API validates the token with the Admin SDK verifyIdToken(), which returns the uid. That uid becomes the key of the users table in PostgreSQL.
According to Firebase’s pricing page, authentication remains free up to 50,000 monthly active users, with phone sign-in billed per SMS sent. If you ever want to leave authentication too, you can export accounts with firebase auth:export, keeping in mind that passwords come out with Firebase’s modified scrypt hash.
Supabase or your own backend with PostgreSQL: which should you choose?
Choose Supabase if you want to keep the BaaS experience: an SDK on the front end, with authentication, realtime, and storage ready to use, PostgreSQL underneath, and a São Paulo region. It is the swap that changes the architecture of a Firebase app the least.
Choose your own backend if you prefer to control the API, use any ORM or framework, authorize on the server, and pay a fixed price in reais. On Zenifra, the same Console has the application, PostgreSQL, queues, Scheduled Jobs, and Storage, billed by PIX or boleto and without IOF. The cost is writing the API and deciding how to do realtime, if the app needs it.
What replaces Firestore realtime in your own backend?
A WebSocket or Server-Sent Events connection opened by your API. On Zenifra, these connections work over the project’s HTTP port, including on custom domains, so you do not need a separate service.
With more than one API instance, each client stays connected to one of them, and the Zenifra docs recommend a shared channel, such as Valkey Cache pub/sub, so a change made on one instance reaches the clients of all of them. Firestore’s offline SDK cache has no ready-made equivalent and has to be built into the app, if you need it.
How much does a PostgreSQL backend cost on Zenifra?
The smallest setup with an app and PostgreSQL is Basic (R$29.90) with DB-Starter (R$11.90), R$41.80 per month plus disk; Static (R$5.90) is for static sites only.
A dynamic API on the Basic plan (R$29.90) with DB-Starter and 5 GB of disk comes to R$42.80 per month. The typical app in this guide, with a worker, a queue, a daily Job, and 20 GB of Storage, comes to R$120.32 per month, all in reais and paid by PIX, boleto, or card.