This sample showcases how to seamlessly add authentication and user management to your JavaScript app using Frontegg’s hosted login method.
- Redirect users to Frontegg’s hosted login
- Enable a fully integrated self-service portal
- Manage and track user authentication state
- Access and display user profile details
- Handle account state and data with ease
- Implement seamless account switching functionality
src/app.js- Main application file with Frontegg initializationsrc/components/- UI components for displaying user and tenant informationsrc/styles/globals.css- Global styling for the applicationpublic/index.html- HTML template
- Node.js
- npm (comes with Node.js)
You’ll also need a Frontegg account. Sign up for free to get started.
Don’t have an account yet? No worries. This project includes sandbox credentials so you can test it right away!
If you don’t have a Frontegg account or prefer to use the sandbox credentials, feel free to skip to step 2.
If you're using your own credentials, follow the guidelines below.
- Go to Frontegg Portal
- Get your application ID from [ENVIRONMENT] → Applications
- Get your Frontegg domain from the Frontegg Portal → [ENVIRONMENT] → Keys & domains
- This sample runs on
http://localhost:3000. You may need to addhttp://localhost:3000under → [ENVIRONMENT] → Keys & domains → Allowed origins - This sample runs on
http://localhost:3000. If your application uses a different port, make sure to addhttp://localhost:3000under → [ENVIRONMENT] → Authentication → Login method → Redirect URLs - Update your own application's credentials under
contextOptions
Run the following command:
git clone <repo>Run the following command:
npm installTo start the application, run:
npm startThe app will be available at http://localhost:3000.

