You can find a demo at https://webflow-authentication.webflow.io/sign-up.
Log in to Firebase console. Create a new app and from the left side menu, under Develop
, navigate to Authentication
. Enable Email/Password
sign-in provider. After this, create a Web application under the current Firebase project and copy the given firebaseConfig object.
Go to the project settings and Custom Code
tab. Add content from webflow-custom-code-before-body.html
gist file to Footer Code
input. Replace webflowAuth.firebaseConfig
with the one you copied in the previous step. After this go to designer and create 3 new pages:
/user
page which is meant for logged in users./log-in
page which is used for logging in./sign-up
page which is used for signing up.
On /sign-up
page, create a form and inside it add a submit button plus two input fields - email and password. Then do the following adjustments:
- Give form element (form element inside form, Form > Form) custom data attribute called
data-signup-form
. - Give email field custom data attribute called
data-signup-email
. - Give password field custom data attribute called
data-signup-password
. - Give form error element custom data attribute called
data-signup-error
. - Add custom data attribute called
data-user-unauth
to the body element.
On /log-in
page, create a form and inside it add a submit button plus two input fields - email and password. Then do the following adjustments:
- Give form element (form element inside form, Form > Form) custom data attribute called
data-login-form
. - Give email field custom data attribute called
data-login-email
. - Give password field custom data attribute called
data-login-password
. - Give form error element custom data attribute called
data-login-error
. - Add custom data attribute called
data-user-unauth
to the body element.
On /user
page add custom data attribute called data-user-auth
to the body element. In addition to this, you can show any user properties returned from Firebase by giving an element custom data attribute called data-user
. After this you can use user properties with curly bracets i.e. Your email is {{email}}
.
If you have a navigation element from which you can navigate to /log-in
, /sign-up
etc. pages, you can adjust their visibility by using custom data attributes called data-user-auth
and data-user-unauth
. You can also add either one of those data attributes to body element which will adjust visibility of the given page. Log out button can be created by giving a link element a custom data attribute called data-logout
.
Some of the ideas are taken from the YouTube video series by Jason Dark which you can find at https://www.youtube.com/watch?v=30AIpEnsEaQ&list=PL4TuDUnZkkhzSwfbFj6EJjxim6218ORc0.
Hello tunnela, thank you for this integration works well. I have a question, I'm trying to also integrate realtime database so I added first the database script call at the top, after the firebase-auth.js and then the database URL into the firebaseConfig area + script to load to get the snapshot to the database. When I published it I get an error "provider.ts:108 Uncaught TypeError: Cannot read property 'instanceIdentifier' of undefined". I recreated just my call to the realtime database in a html file and it worked in the console without error. Do I'm missing something? :) I also noticed this part "firebase.analytics && firebase.analytics();" I need to initialize similar my database? Thank you in advance for read me