0
0
Firebasecloud~5 mins

Email/password signup in Firebase - Commands & Configuration

Choose your learning style9 modes available
Introduction
Creating an email and password signup lets users create accounts securely. This solves the problem of identifying users and managing access without complicated setups.
When you want users to register with their email and a password to access your app.
When you need a simple way to manage user accounts without social logins.
When you want to protect parts of your app so only signed-up users can use them.
When you want to send password reset emails to users who forget their password.
When you want to track user activity linked to their email identity.
Config File - firebase.json
firebase.json
{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/**",
        "destination": "/index.html"
      }
    ]
  }
}

This file configures Firebase hosting.

hosting: Sets up where your app files are served from.

Note: Authentication sign-in methods are configured in the Firebase Console, not in firebase.json.

Commands
Log in to your Firebase account to allow CLI commands to access your projects.
Terminal
firebase login
Expected OutputExpected
✔ Success! Logged in as user@example.com
Initialize Firebase Authentication in your project to enable email/password signup.
Terminal
firebase init auth
Expected OutputExpected
=== Authentication Setup === ✔ Authentication enabled ✔ Email/Password sign-in method enabled Firebase Authentication has been initialized.
Deploy the hosting configuration to Firebase so your app is served.
Terminal
firebase deploy --only hosting
Expected OutputExpected
=== Deploying to 'your-project-id' === ✔ hosting: Successfully deployed Project Console: https://console.firebase.google.com/project/your-project-id/overview ✔ Deploy complete!
--only - Deploy only the specified Firebase feature, here hosting.
Import users with hashed passwords to Firebase Authentication (example for advanced use).
Terminal
firebase auth:import users.json --hash-algo=SCRYPT --hash-key=base64Key --salt-separator=base64Salt --rounds=8 --mem-cost=14
Expected OutputExpected
✔ Successfully imported users.
List all users registered in Firebase Authentication to verify the new signup.
Terminal
firebase auth:list
Expected OutputExpected
Users: - user@example.com (UID: abc123def456)
Key Concept

If you remember nothing else from this pattern, remember: enabling and deploying email/password authentication in Firebase lets users securely create accounts with just their email and a password.

Common Mistakes
Not enabling the email/password sign-in method in Firebase console.
Users cannot sign up or log in without this method enabled.
Always enable email/password sign-in in Firebase Authentication settings before deploying.
Using weak or simple passwords during signup.
Weak passwords reduce security and can lead to account compromise.
Use strong passwords with letters, numbers, and symbols for user accounts.
Not deploying hosting changes after updating config.
Changes won't take effect until deployed, so signup won't work as expected.
Run 'firebase deploy --only hosting' after any hosting config changes.
Summary
Use 'firebase init auth' to enable email/password signup in your Firebase project.
Enable email/password sign-in method in Firebase Console under Authentication > Sign-in method.
Deploy hosting settings with 'firebase deploy --only hosting' to serve your app.
Create and verify users with Firebase Authentication SDK or Admin SDK; CLI commands for user creation are not standard.
Use 'firebase auth:list' to list users.