To set up user authentication on a Webflow site without using Firebase UI, you’ll need to integrate Firebase Authentication manually using custom forms, JavaScript, and Webflow’s native form elements for full design control.
- Go to the Firebase Console and create a new project.
- Enable Authentication from the left menu and select Email/Password (or other desired providers like Google, GitHub, etc.).
- Go to Project Settings > General and copy your Firebase Web Config (apiKey, authDomain, etc.).
2. Add Firebase SDK Script to Webflow
- In Webflow, go to Project Settings > Custom Code.
- In the Footer section, add the Firebase SDK scripts from the official CDN:
- Firebase core (
https://www.gstatic.com/firebasejs/10.0.0/firebase-app.js
) - Firebase Auth (
https://www.gstatic.com/firebasejs/10.0.0/firebase-auth.js
) - Also include a script that initializes Firebase with your project’s config.
- Use Webflow’s native form elements to build your custom:
- Sign-up form (email, password)
- Login form (email, password)
- Optional: Password reset form
- Assign custom IDs or class names to form elements to target them via JavaScript.
- Inside the Custom Code Footer (or via Webflow’s Embed element), write JavaScript that:
- Prevents native form submission
- Extracts form input values
- Uses Firebase tokens to sign up or log in users via the Firebase JavaScript SDK
- Example methods:
createUserWithEmailAndPassword()
, signInWithEmailAndPassword()
5. Manage Auth State and Redirects
- Use
onAuthStateChanged()
to monitor login state. - Redirect users to protected pages or hide/show elements based on auth status.
- Example: If user is not logged in, redirect them to the login page.
6. Secure Protected Pages (Client-Side Only)
- In each protected page’s Page Settings > Custom Code > Footer, add a script that:
- Checks if a user is logged in through
firebase.auth().currentUser
- If not logged in, redirects to the login page
- For added control, you can store the user token in
localStorage
or sessionStorage
.
7. Optional: Logout Functionality
- Add a “Logout” button and attach a JavaScript
click
handler that calls firebase.auth().signOut()
. - On successful logout, redirect the user to the homepage or login screen.
Summary
To enable user authentication with custom form control on a Webflow site, integrate Firebase Authentication via the SDK, create Webflow-based forms, and handle interactions using JavaScript. This setup lets you fully own the front-end design while benefiting from Firebase’s secure backend auth services.