# Firebase

> Add sign-in and a database to a web or phone app, and keep information up to date across devices.

Web page: https://buildladder.com/tools/firebase

Think of a shared grocery list. When one person marks milk as bought, the other person wants to see the change while they are still in the shop. Firebase’s Firestore database lets an app listen for changes to the saved list.

Start with one sample list and open it on two devices allowed to read it. Check off an item on one screen and watch the other. You can see what your app feels like to two people using it together.

- Made by: Google
- Official site: https://firebase.google.com
- Cost: Free Spark plan, no card needed. Firestore includes 1 GiB stored, 50,000 reads and 20,000 writes a day. The Blaze plan is pay as you go.
- What you need first: A Google account.
- Who it helps: When your product needs to save data or have user accounts, especially if you already use Google’s tools.
- When to skip it: If you want your data in tables with rows and columns, Supabase may suit you better.
- Updated: 2026-11-10

## Save data with Firebase

Give your product a database so it remembers things between visits. Cloud Firestore keeps your data as documents, and Security Rules decide who can read and change them.

What you’ll end up with: Your product saves and loads real data in Cloud Firestore. Each person can only reach the data they’re allowed to.

### You’ll need

- A website or app with PLAN.md in its folder.
- Your AI tool, set up and working in that folder.
- A Google account.
- Firebase sign-in, if each person should see only their own data. “Add sign-in with Firebase” sets it up.
- Firebase account (https://console.firebase.google.com): Free Spark plan, no card needed. Firestore includes 1 GiB stored, 50,000 reads and 20,000 writes a day. The Blaze plan is pay as you go

### Your part

- Create or open the Firebase project, then create the Firestore database.
- Read what each rule does, then publish the Security Rules.
- Test with two accounts, and in the Rules Playground, before real people use it.

### Step 1 of 5: Create or open your Firebase project and add a database

This step is mine to do. Walk me through it, one action at a time:
- If you already have a Firebase project for this product, such as one made for sign-in, open it at console.firebase.google.com. Then go straight to Databases & Storage.
- Otherwise, go to console.firebase.google.com and sign in with your Google account.
- Choose the option that creates a project. Name it after your product and finish the form.
- On the project overview, start adding a web app. An Expo app uses this web setup too, and it works in Expo Go.
- Enter a nickname for the web app and finish registering it.
- In the left menu, open Databases & Storage, then Firestore. Click Create database.
- Pick a location close to the people who will use your product.
- Choose Production mode, then click Create. It blocks all reads and writes from apps until you write rules.

It worked when: Your Firebase project has an empty Firestore database, locked until you add rules.

If something goes wrong:
- You picked Test mode by mistake. Test mode lets anyone read and change your data. “Set who can read and write” fixes it, so don’t add real data until then.
- You can’t choose a location. Your project’s location was already set. That’s fine. Carry on with the location shown.

### Step 2 of 5: Design your first collection

Read PLAN.md in this folder. It has my plan and the tools I chose. I’m using Cloud Firestore from Firebase for my database.

Help me design the first collection, or the first few, for the must-have features only. Check Firebase’s current official docs first. Don’t rely on memory.

Explain in plain words:
- what each collection holds, with an example document
- which fields each document has, and what each one means
- which documents belong to one person, and how we’ll know who owns each one

Wait for my yes. Then write Firestore Security Rules for these collections in a firestore.rules file in this product:
- signed-in people can only read and change their own documents, unless I said otherwise
- everything else stays blocked
- each rule has a plain-English comment

Don’t deploy anything to my Firebase project. I’ll publish the rules myself.

It worked when: Your AI tool has explained your collections in plain words and written a firestore.rules file with commented rules.

Before we move on, check with me:
- Does each collection match something in your PLAN.md?
- Can you say in your own words who can read each collection?

If something goes wrong:
- The plan has more than you expected. Say: “Keep only what the must-have features need. We can add more later.”
- You don’t know what should be private. Think about who should see each thing. Notes might be private, while a shop’s products are public. Tell your AI tool in plain words.

### Step 3 of 5: Set who can read and write

This step is mine to do. Walk me through it, one action at a time:
- Read the plain-English comments in firestore.rules. If any rule surprises you, ask your AI tool to change it first.
- In the Firebase console, open Databases & Storage, then Firestore, then the Rules tab.
- Replace what’s in the editor with the whole firestore.rules file.
- Open Rules Playground. Try reading a document as a signed-in person who does not own it, then start the test. It should be denied.
- Click Publish. New rules can take a minute to work, and up to 10 minutes to reach everything.
- Each time you add a collection later, update firestore.rules and publish it again.

It worked when: Your rules are published in Firestore, and the playground turns away someone who doesn’t own the document.

If something goes wrong:
- Publishing shows an error in the rules. Copy the error and its line number to your AI tool. Ask it to fix firestore.rules, then paste in the new version.
- You don’t know what to try in the playground. Ask your AI tool: “Give me one Rules Playground test that should be denied, step by step.”

### Step 4 of 5: Save and load data in your app

Read PLAN.md again. My Firestore database is set up, and my Security Rules are published.

Connect my app to Firestore. Check Firebase’s current docs for my kind of product first. Then:
1. Add my Firebase config to the app. Read the values from environment variables, and put the names in .env with empty values for me to fill. Make sure Git ignores .env, and tell me where to find each value in the Firebase console.
2. If my app doesn’t have sign-in yet, ask me before adding Firebase Authentication with email and password.
3. Let people add, see, change and delete their own documents, for the first must-have feature only. Save the owner’s user ID on each one, matching my rules.
4. Show a clear message if saving or loading fails, and a friendly message when nothing is saved yet.

Never add an admin key, like a service account key, to the app. Those skip my rules. Tell me what you’ll install or change before you do it. Keep everything that already works. When you’re done, give me a short list of things to try.

It worked when: Your product saves something, and it’s still there after you refresh the page or reopen the app.

Before we move on, check with me:
- In Firestore, can you see the document you added?

If something goes wrong:
- It says permission denied, or missing permissions. Your rules blocked the request. Say: “Firestore is blocking this. Compare my code with firestore.rules and fix the smallest thing.”
- The AI tool says the Firebase API key must be secret. Google says Firebase API keys are safe to include in app code. Your rules protect the data. Admin keys, like service account keys, must stay secret.

### Step 5 of 5: Test with two accounts

This step is mine to do. Walk me through it, one action at a time:
- Sign in to your product as yourself and add two or three items.
- Sign out. Sign up as a second test person, using another email address.
- As the second person, check that the first person’s items don’t appear. Add one item of your own.
- Sign out and sign back in as yourself. Check that you only see your own items.
- Open Firestore in the Firebase console. Check that each document has the owner your AI tool designed for it.
- To test without real accounts, ask your AI tool to set up the Firebase Local Emulator Suite. It runs on your computer and needs Java.

It worked when: Each test account sees only its own items.

Before we move on, check with me:
- Did your own items come back after you signed in again?

If something goes wrong:
- The second person can see the first person’s items. Stop and fix this first. Say: “My second test account can see the first account’s data. Check my access rules and code, and fix them.”
- Sign-up gets blocked after a few tries. Firebase allows 100 new accounts an hour from one internet connection. Wait a while, then try again.

Compare Firebase with the other options: https://buildladder.com/concepts/databases.md

## Add sign-in with Firebase

Let people create an account and sign in with their email or Google. Firebase Authentication keeps the accounts, and your AI tool builds the pages in your product.

What you’ll end up with: People can sign up, sign in with email or Google, and sign out. One page in your product is only for signed-in people.

### You’ll need

- A website or app with PLAN.md in its folder.
- Your AI tool, set up and working in that folder.
- A Google account.
- Firebase account (https://console.firebase.google.com): Free Spark plan, no card needed, with 50,000 monthly active users. The Blaze plan is pay as you go

### Your part

- Create the Firebase project and register your web app.
- Turn on email and Google sign-in in the Firebase console.
- Sign up and sign in to check that it all works.

### Step 1 of 7: Create or open your Firebase project

This step is mine to do. Walk me through it, one action at a time:
- If you already have a Firebase project for this product, open it at console.firebase.google.com and skip the rest of this list.
- Otherwise, go to console.firebase.google.com and sign in with your Google account.
- Choose the option that creates a project. Name it after your product and finish the form.
- On the project overview, start adding a web app. An Expo app uses this web setup too, and it works in Expo Go.
- Enter a nickname for the web app and finish registering it.

It worked when: Your web app is listed under Project settings in your Firebase project.

If something goes wrong:
- You don’t see the Web choice. If the project already has an app, click Add app first. The choices appear after that.

### Step 2 of 7: Turn on email sign-in and check web addresses

This step is mine to do. Walk me through it, one action at a time:
- Open Firebase Authentication from the console menu. If it shows a button to get started, click it.
- Open Sign-in method. Turn on Email/Password, then save.
- Open the Settings tab, then Authorized domains.
- If localhost isn’t in Authorized domains, add it, so sign-in works while your product runs on your computer.
- When you put your product online, add its live address to Authorized domains and remove localhost.

It worked when: Email/Password shows as on under Sign-in method, and Authorized domains lists localhost.

If something goes wrong:
- You can’t find Authentication. Look under Security in the left menu. Older screens may list it under Build.

### Step 3 of 7: Add sign-up and sign-in pages

Read PLAN.md in this folder. It has my plan and the tools I chose.

I want people to sign up, sign in and sign out with Firebase Authentication. I have a Firebase project with my web app registered and Email/Password turned on.

Before you start:
- Look at my product and tell me how it’s built, in plain words.
- Check Firebase’s current official docs for this kind of product. Don’t rely on memory.
- Tell me what you’ll install and change, and wait for my yes.

Then:
1. If my app isn’t connected to Firebase yet, add the names for my Firebase config to .env, with empty values. Make sure Git ignores it. Tell me where to find each value in the Firebase console. I’ll paste them in myself.
2. Never add an admin key, like a service account key, to code that runs in a browser or on a phone.
3. Build a sign-up page and a sign-in page with email and password. Show clear messages when something goes wrong, like a wrong password.
4. Add a “Continue with Google” button. Check Firebase’s redirect best practices before you choose between a popup and a redirect. It won’t work until I turn Google on, and that’s fine.
5. Add a way to sign out, and show who is signed in.

Keep everything that already works. When you’re done, explain what changed and give me a short list of things to try.

It worked when: Your product has sign-up and sign-in pages, and your .env file holds your Firebase config values.

Before we move on, check with me:
- Does the sign-up page show the form and the Google button?
- Does your AI tool confirm that Git ignores .env?

If something goes wrong:
- The AI tool says the Firebase API key must be secret. Google says Firebase API keys are safe to include in app code. Your rules protect the data. Admin keys, like service account keys, must stay secret.
- It says auth/unauthorized-domain. Your product’s address isn’t in Authorized domains. Add it on the Settings tab under Authentication, then try again.

### Step 4 of 7: Turn on Google sign-in

This step is mine to do. Walk me through it, one action at a time:
- In Firebase Authentication, open Sign-in method.
- Find Google in the list of providers and turn it on.
- If it asks for a support email, pick your own address.
- Click Save.
- Open your product and click the Google button. Pick your Google account.

It worked when: You can sign in to your product with Google and land back in it, signed in.

If something goes wrong:
- Google sign-in fails in Safari or Firefox after the redirect. Those browsers block the storage that Firebase’s redirect uses. Say: “Follow Firebase’s redirect best practices and fix Google sign-in for my setup.”
- The popup closes and nothing happens. Your browser may have blocked it. Allow popups for your product’s address, or ask your AI tool to use a redirect instead.

### Step 5 of 7: Phone app only: keep people signed in and add Google

This step is mine to do. Walk me through it, one action at a time:
- Tell your AI tool: “This is an Expo app using the Firebase JS SDK. Keep people signed in after the app closes, following Expo’s Firebase guide.”
- Google sign-in on a phone needs a development build, because the Google sign-in library can’t run in Expo Go. Ask your AI tool to make one with Expo’s guide.
- In Firebase’s Project settings, register each phone platform you support. Ask your AI tool for the identifiers that platform’s form needs.
- Download the configuration file for each platform you added: google-services.json for Android, GoogleService-Info.plist for iOS. Put it in your product’s folder.
- Tell your AI tool: “Add Google sign-in with a development build, following Expo’s Google authentication guide and Firebase’s current docs. Use the configuration files I added.”

It worked when: People stay signed in after closing the app, and Google sign-in works in a development build.

Before we move on, check with me:
- Does Project settings list each phone platform you added under Your apps?

If something goes wrong:
- Google sign-in does nothing in Expo Go. That’s expected. Ask your AI tool to make a development build and test Google there.
- You don’t know your SHA-1 fingerprint. Ask your AI tool: “Show me the SHA-1 fingerprint for my Android build, for testing and for the Play Store.”

### Step 6 of 7: Make a page for signed-in people only

Read PLAN.md again. I want one page that only signed-in people can see. If you don’t know which page, ask me first.

Check Firebase’s current docs for this kind of product. Then:
- If someone who isn’t signed in opens that page, send them to the sign-in page.
- After they sign in, take them back to the page they wanted.
- Hiding a link isn’t enough. Any private data on that page must also be protected by Firebase Security Rules, not only by the page.

Keep everything that already works. Tell me what you changed, and how to test it while signed in and signed out.

It worked when: The page opens when you’re signed in, and sends you to sign in when you’re not.

If something goes wrong:
- The page opens even when you’re signed out. Say: “I’m signed out and the protected page still opens. Please find out why and fix it.”

### Step 7 of 7: Test sign-up, sign-out and Google

This step is mine to do. Walk me through it, one action at a time:
- Sign up with your own email and a password.
- Sign out. Then open your page for signed-in people. It should send you to sign in.
- Sign in with your email and password. That page should open.
- Sign out again. Click Continue with Google and pick your Google account.
- Open Users in Firebase Authentication. Check that your test sign-ups are listed.

It worked when: Email sign-up, sign-out, sign-in and Google sign-in all work, and your test accounts appear in Firebase.

If something goes wrong:
- Sign-up gets blocked after a few tries. Firebase allows 100 new accounts an hour from one internet connection. Wait a while, then try again.
- Password reset emails stop arriving. The free Spark plan sends 150 password reset emails a day. Check your spam folder, or wait until tomorrow.

Compare Firebase with the other options: https://buildladder.com/concepts/sign-in.md
