How can user authentication be set up on a Webflow site without using Firebase UI and instead building custom forms for full control over the site's appearance and functionality?

TL;DR
  • Create a Firebase project, enable authentication, and copy the web config object.  
  • Build custom login/signup forms in Webflow with unique IDs.  
  • Embed Firebase config and auth logic using JavaScript to handle form submissions.  
  • Use onAuthStateChanged() to manage login state and control access or redirects on the frontend.  
  • Secure backend access with Firebase security rules based on authentication state.

To set up user authentication on a Webflow site using custom forms, while avoiding Firebase UI, you'll need to manually integrate Firebase Authentication with Webflow through custom JavaScript and form elements.

1. Set Up Firebase Project

  • Go to Firebase Console and create a new project.
  • Enable Email/Password authentication (or any other method you wish) under Authentication > Sign-in method.
  • Go to Project Settings > General, then under Your apps, click Add app > Web and copy the configuration object (apiKey, authDomain, etc.).

2. Add Custom Form Elements in Webflow

  • Use Webflow Designer to build your sign-uplog-in, and log-out forms with standard HTML elements (input, submit button, etc.).
  • Assign unique IDs or classes to form inputs (e.g., #email#password) and buttons (e.g., #signup-btn#login-btn).

3. Embed Firebase Auth Logic with Custom JavaScript

  • In Webflow, go to Page Settings or use a custom Embed element.
  • Paste your Firebase config and initialization script (inside <script> tags).
  • Add event listeners for your custom form buttons that use firebase.auth() functions like createUserWithEmailAndPassword() and signInWithEmailAndPassword().
  • Example minor inline reference: firebase.auth().onAuthStateChanged() can be used to check login state.

4. Handle Form Submission and Authentication State

  • Prevent default form submission using event.preventDefault().
  • Use Firebase methods to create or verify users.
  • After login, use JavaScript to redirect users (window.location.href = "/dashboard") or conditionally show/hide content.
  • Store user state with session storage or use Firebase’s built-in state persistence.

5. Set Up Page Access Control (Frontend Logic)

  • Because Webflow doesn’t support server-side logic, use client-side checks:
  • On page load, use onAuthStateChanged() to verify if the user is logged in.
  • If not authenticated, redirect or block access to private pages.
  • Hide/show navigation or gated content based on the user’s login state using DOM manipulation.

6. Secure Backend Data Access (If Needed)

  • If your site communicates with Firebase Cloud Functions, Firestore, or any external API, use Firebase security rules to restrict data access based on authentication state.

Summary

To set up user authentication without Firebase UI, build custom forms in Webflow, integrate Firebase manually using JavaScript, and control appearance and functionality entirely yourself. Use client-side logic for login state management and Firebase security rules to protect any backend data.

Rate this answer

Other Webflow Questions