Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndrewwCO/Pana-Baker/llms.txt

Use this file to discover all available pages before exploring further.

Panahashi Baker uses Firebase Authentication to identify bakery owners, obtain ID tokens, and pass them to the backend API on every request. The firebase package is already listed in package.json, so you only need to create a Firebase project, add your config, and enable the right sign-in methods.
src/services/auth.js references a firebaseConfig object that is not defined in the file — the app will crash on startup until you add it. The demo placeholder must be replaced with a real Firebase project config before you run or build the app.
1

Create a Firebase project

Go to the Firebase console, create a new project, and register a web app inside it. Firebase will generate a config object for you after registration — you will copy those values in the next step.
2

Add firebaseConfig to auth.js

Open src/services/auth.js and add your config object at the top of the file, before the getApps() call:
// src/services/auth.js
const firebaseConfig = {
  apiKey:            "YOUR_API_KEY",
  authDomain:        "YOUR_PROJECT_ID.firebaseapp.com",
  projectId:         "YOUR_PROJECT_ID",
  storageBucket:     "YOUR_PROJECT_ID.appspot.com",
  messagingSenderId: "YOUR_SENDER_ID",
  appId:             "YOUR_APP_ID",
};
All six fields are required. Copy the exact values from your Firebase project settings — do not guess or reuse values from another project.
3

Verify the Firebase import

The firebase package (^12.13.0) is already installed. src/services/auth.js imports from it using the modular SDK:
import { initializeApp, getApps, getApp } from "firebase/app";
import {
  initializeAuth,
  getReactNativePersistence,
  onAuthStateChanged,
  signOut,
  signInWithEmailAndPassword,
} from "firebase/auth";
import AsyncStorage from "@react-native-async-storage/async-storage";
No additional installation step is needed — npm install during project setup already handled this.
4

Enable Email/Password sign-in

In the Firebase console, open Authentication → Sign-in method and enable the Email/Password provider. This is the only provider Panahashi Baker uses. The login() function in auth.js calls signInWithEmailAndPassword(auth, email, password) directly.
5

Enable Firebase Storage

In the Firebase console, open Storage and click Get started. Panahashi Baker uploads product photos, bakery logos, and banners through the backend API (/upload/* endpoints), which in turn writes to Firebase Storage. Without Storage enabled, image uploads will fail at the server side.

How session persistence works

Auth state is persisted across app restarts using AsyncStorage. initializeAuth is called with getReactNativePersistence(AsyncStorage), which means bakery owners stay logged in between sessions without re-entering their credentials.
The onAuthStateChanged listener in AuthProvider is the single source of truth for the current user. When Firebase restores a session or a new login succeeds, it fires with the signed-in user and the app immediately fetches a fresh ID token:
// src/services/auth.js — useEffect inside AuthProvider
const unsubscribe = onAuthStateChanged(auth, async (firebaseUser) => {
  try {
    if (firebaseUser) {
      const token = await firebaseUser.getIdToken();
      api.setToken(token);
      api.setUserName(firebaseUser.displayName || "Baker");
      setUser({
        uid:         firebaseUser.uid,
        displayName: firebaseUser.displayName,
        email:       firebaseUser.email,
      });
    } else {
      api.setToken(null);
      setUser(null);
    }
  } catch (error) {
    console.log("Auth error:", error);
  }
  setLoading(false);
});

return unsubscribe;
The token is passed to api.setToken(token) so every subsequent API call includes it as a Bearer header. When the user logs out, api.setToken(null) clears it immediately.

Connecting to your backend API

See how the token is attached to every API request.

Building with EAS

Package the app for Android and iOS distribution.

Build docs developers (and LLMs) love