This repository contains the code of four JavaScript projects showing how to create a Web Component and using it across different frameworks. You will find the following projects:
- auth0-login-button. This project implements a login button Web Component that authenticates with Auth0
- secure-angular-app. This is a basic Angular app using the Auth0 login button
- secure-react-app. This is a basic React app using the Auth0 login button
- secure-vue-app. This is a basic Vue app using the Auth0 login button
The following article describes the implementation details: Beyond JavaScript Frameworks: Build a Universal Login Button as a Web Component
- Node.js installed on your machine
- An Auth0 account.
- Angular CLI installed on your machine (to run the Angular project)
- Vue CLI installed on your machine (to run the Vue project)
-
Clone this repo:
git clone https://github.com/auth0-blog/auth0-login-button.git -
Move into the
auth0-login-button/auth0-login-buttonfolder -
Run the following command (it may require admin privileges)
npm link
This command makes the project available as if it was an npm package.
-
Register an Auth0 application and get the domain and the client id.
- Move into the
auth0-login-buttonfolder - Replace the YOUR_DOMAIN and YOUR_CLIENT_ID placeholders in the
/dist/index.htmlfile with your Auth0 domain and client id - Add
http://localhost:8080as an allowed callback and logout URL in the Auth0 dashboard - Run
npm installcommand - Run
npm startcommand
- Move into the
secure-angular-appfolder - Replace the YOUR_DOMAIN and YOUR_CLIENT_ID placeholders in the
/src/app/app.component.tsfile with your Auth0 domain and client id - Add
http://localhost:4200/as an allowed callback and logout URL in the Auth0 dashboard - Run
npm installcommand - Run
npm link 'auth0-login-button'command - Run
ng servecommand
- Move into the
secure-react-appfolder - Replace the YOUR_DOMAIN and YOUR_CLIENT_ID placeholders in the
/src/App.jsfile with your Auth0 domain and client id - Add
http://localhost:3000/as an allowed callback and logout URL in the Auth0 dashboard - Run
npm installcommand - Run
npm link 'auth0-login-button'command - Run
npm startcommand
- Move into the
secure-vue-appfolder - Replace the YOUR_DOMAIN and YOUR_CLIENT_ID placeholders in the
/src/App.vuefile with your Auth0 domain and client id - Add
http://localhost:8080as an allowed callback and logout URL in the Auth0 dashboard - Run
npm installcommand - Run
npm link 'auth0-login-button'command - Run
npm run servecommand