<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anthony Dombrowski</title>
    <description>The latest articles on DEV Community by Anthony Dombrowski (@akdombrowski).</description>
    <link>https://dev.to/akdombrowski</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F186749%2Ff0b1866e-6da0-4dd8-b01b-dcf1b72dff51.png</url>
      <title>DEV Community: Anthony Dombrowski</title>
      <link>https://dev.to/akdombrowski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akdombrowski"/>
    <language>en</language>
    <item>
      <title>Add Authentication to your React App with Frontegg</title>
      <dc:creator>Anthony Dombrowski</dc:creator>
      <pubDate>Fri, 28 Mar 2025 21:59:47 +0000</pubDate>
      <link>https://dev.to/akdombrowski/add-authentication-to-your-react-app-with-frontegg-c6c</link>
      <guid>https://dev.to/akdombrowski/add-authentication-to-your-react-app-with-frontegg-c6c</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4hso6slieh4fjwjvyxq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4hso6slieh4fjwjvyxq.gif" alt="frontegg-vite-react-ts" width="800" height="616"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a quick start guide with &lt;a href="https://github.com/akdombrowski/frontegg-vite-react-ts" rel="noopener noreferrer"&gt;an accompanying sample app&lt;/a&gt; on integrating authentication into a client-side React app using Frontegg's React SDK.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is this for you?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You’re looking to for an IdP, authentication, authorization, OAuth/OIDC login and SSO, user management&lt;/li&gt;
&lt;li&gt;You’re working with a client-side React app (SPA)

&lt;ul&gt;
&lt;li&gt;The Frontegg React SDK is specifically designed for client-side React apps&lt;/li&gt;
&lt;li&gt;If that’s not you, you may want to see if any of the other SDKs offered here meet your needs:

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.frontegg.com/sdks/overview" rel="noopener noreferrer"&gt;https://developers.frontegg.com/sdks/overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Most of what will be talked about here is abstract enough to apply to the other tech stacks as well&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;The accompanying sample app uses Vite and their React (with Typescript) template as a starting point.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites to follow along:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Sign up for Frontegg
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://portal.frontegg.com/signup" rel="noopener noreferrer"&gt;https://portal.frontegg.com/signup&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Download the Sample App
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/akdombrowski/frontegg-vite-react-ts" rel="noopener noreferrer"&gt;https://github.com/akdombrowski/frontegg-vite-react-ts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  At least Node 20 (LTS)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/download" rel="noopener noreferrer"&gt;NodeJS Downloads&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quickstart for Frontegg and React
&lt;/h2&gt;

&lt;p&gt;Vite React w/ Typescript and Frontegg is a minimal sample app to get started with &lt;a href="https://frontegg.com" rel="noopener noreferrer"&gt;Frontegg&lt;/a&gt; Authentication in a &lt;a href="https://react.dev/" rel="noopener noreferrer"&gt;React app&lt;/a&gt; using &lt;a href="https://github.com/frontegg/frontegg-react" rel="noopener noreferrer"&gt;Frontegg's client-side React SDK&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The app is bootstrapped with &lt;a href="https://vite.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt; and their &lt;a href="https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts" rel="noopener noreferrer"&gt;React template (with Typescript)&lt;/a&gt;, but &lt;a href="https://github.com/frontegg/frontegg-react" rel="noopener noreferrer"&gt;Frontegg's React SDK&lt;/a&gt; can be used in any client-side React app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frontegg Application Configuration
&lt;/h3&gt;

&lt;p&gt;From within the &lt;a href="https://portal.frontegg.com/login" rel="noopener noreferrer"&gt;Frontegg admin dashboard&lt;/a&gt;, &lt;a href="https://developers.frontegg.com/guides/management/multi-apps/overview#create-and-configure" rel="noopener noreferrer"&gt;create an Application&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, make sure you configure at least these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enter a name.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tip.

&lt;ul&gt;
&lt;li&gt;Ideally, aim for a descriptive name that’s easily understandable for anyone that may end up becoming a Frontegg admin. And, if you intend to allow self-service configuration, this name will be visible to customers/users.&lt;/li&gt;
&lt;li&gt;If you only intend to use this app for testing, go ahead and get creative with it (or not).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Type&lt;/strong&gt; = &lt;code&gt;Web&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Frontend stack&lt;/strong&gt; = &lt;code&gt;React&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;App URL&lt;/strong&gt; = &lt;code&gt;http://localhost:5173&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the url where you're app is running&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;http://localhost:5173&lt;/code&gt; is the default url in Vite development mode (a.k.a. when running &lt;code&gt;npm run dev&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;ℹ️ Your app config in the &lt;a href="https://portal.frontegg.com/login" rel="noopener noreferrer"&gt;Frontegg admin dashboard&lt;/a&gt; should look something like this:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7smkvozq6ss16h8etl3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7smkvozq6ss16h8etl3.png" alt="App Config Example" width="284" height="600"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Optional
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-assigned app&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Following the best practice of least privilege, the default setting is that apps need to be assigned to Users in order to login.&lt;/li&gt;
&lt;li&gt;In other words, Users are restricted from authenticating and, therefore, potentially accessing apps they aren’t “assigned”.&lt;/li&gt;
&lt;li&gt;However, to make it easier to manage, apps can be assigned to Users in different ways:&lt;/li&gt;
&lt;li&gt;Assignment Scopes

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;User&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;assigning apps A and B to User 1 but only app A to User 2, then User 2 will be restricted from app B&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Account&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;assigning apps A and B to Account X but only app A to Account Y, then all users in Account 2 will be restricted from app B.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Auto-assigned&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Configuring this assigns this to Accounts and Users, i.e., no one is restricted from it&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;You can also mix and match as you see fit!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Forgot to add the redirect uri
&lt;/h3&gt;

&lt;p&gt;Under &lt;code&gt;Configurations&lt;/code&gt; &amp;gt; &lt;code&gt;Authentication&lt;/code&gt; &amp;gt; &lt;code&gt;Login Method&lt;/code&gt; in your &lt;strong&gt;Frontegg dashboard&lt;/strong&gt;, add a url back to your app.&lt;/p&gt;

&lt;p&gt;For example, when running in Vite dev mode (i.e., &lt;code&gt;npm run dev&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:5173/oauth/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*Modify the hostname and port as needed if you've changed from the defaults or are running in other modes.&lt;/p&gt;

&lt;h3&gt;
  
  
  CORS &amp;amp; Allowed Origins
&lt;/h3&gt;

&lt;p&gt;If you don't configure this, you may open your browser's console to see a bunch of &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/CORS" rel="noopener noreferrer"&gt;'CORS'&lt;/a&gt; errors that say something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at
https://app-abc123.frontegg.com/frontegg/oauth/token.
&lt;span class="o"&gt;(&lt;/span&gt;Reason: CORS header ‘Access-Control-Allow-Origin’ missing&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Status code: 204.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The solution is to add your app's &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Origin" rel="noopener noreferrer"&gt;origin&lt;/a&gt; as an 'Allowed Origin' which lets Frontegg know that it's okay to share (potentially) sensitive information there.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Configure Allowed Origins in the Frontegg Dashboard
&lt;/h4&gt;

&lt;p&gt;Under &lt;code&gt;Configurations&lt;/code&gt; &amp;gt; &lt;code&gt;Keys &amp;amp; domains&lt;/code&gt; &amp;gt; &lt;code&gt;Domains&lt;/code&gt; tab &amp;gt; &lt;code&gt;Allowed Origins&lt;/code&gt; section in your &lt;strong&gt;Frontegg dashboard&lt;/strong&gt;, add your app's origin (the scheme, domain, and port parts of the url: e.g., &lt;a href="http://localhost:5173" rel="noopener noreferrer"&gt;http://localhost:5173&lt;/a&gt; or &lt;a href="https://example.com" rel="noopener noreferrer"&gt;https://example.com&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Required Environment Variables
&lt;/h3&gt;

&lt;p&gt;These are the 3 environment variables &lt;strong&gt;necessary&lt;/strong&gt; for integrating Frontegg along with where to navigate in the admin portal to find their values:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;VITE_FRONTEGG_BASE_URL&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;"Keys &amp;amp; Domains" &amp;gt; "Domains" tab, in the "Frontegg Domain" section labeled as the "Domain Name"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VITE_FRONTEGG_CLIENT_ID&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;"Keys &amp;amp; Domains" &amp;gt; "General" tab, in the "API Key" section labeled as the "Client ID"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VITE_FRONTEGG_APP_ID&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;App ID's are unique per application and can be found by opening a particular Application in the Frontegg Dashboard.&lt;/li&gt;
&lt;li&gt;"Applications" &amp;gt; {name_of_app} &amp;gt; "Settings" tab labeled as the "ID"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;.env.Example&lt;/code&gt; contains the required Frontegg variables used in the app that you can use by simply swapping in your actual config values for the placeholder values.&lt;/p&gt;

&lt;p&gt;To use the template,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;create a copy of the file and name it &lt;code&gt;.env&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vite uses &lt;a href="https://github.com/motdotla/dotenv" rel="noopener noreferrer"&gt;dotenv&lt;/a&gt; to automatically &lt;a href="https://vite.dev/guide/env-and-mode.html#env-files" rel="noopener noreferrer"&gt;load the variables in the &lt;code&gt;.env&lt;/code&gt; file&lt;/a&gt;\*&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;replace the placeholder values with your Frontegg details:&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  The &lt;code&gt;.env&lt;/code&gt; file Template
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;################################################################################
### FRONTEGG CONFIG ###
################################################################################
# ! The 'VITE_' prefix exposes values client-side. !
# This is necessary for Base URL, Client ID, and App ID for the Frontegg React SDK, but take care
# not to expose any secrets!
#
# The "Base URL" and "Client ID" values can be found in the Frontegg Dashboard
# under "Keys &amp;amp; Domains".
#
# "Keys &amp;amp; Domains" &amp;gt; "Domains" &amp;gt; "Domain Name"
# Under the "Domains" tab, in the "Frontegg Domain" section labeled as the "Domain Name"
VITE_FRONTEGG_BASE_URL='https://app-rndCharsHere.frontegg.com'
#
# "Keys &amp;amp; Domains" &amp;gt; "General" &amp;gt; "Client ID"
# Under "General" tab, in the "API Key" section labeled as the "Client ID"
VITE_FRONTEGG_CLIENT_ID='looks-like-a-rnd-uuid'
#
#
# App ID's are unique per application and can be found by opening a particular Application in the
# Frontegg Dashboard.
#
# "Applications" &amp;gt; {name_of_app} &amp;gt; "Settings" &amp;gt; "App ID"
# Under the "Settings" tab labeled as the "ID"
VITE_FRONTEGG_APP_ID='looks-like-a-rnd-uuid-too'
################################################################################
### FRONTEGG CONFIG ###
################################################################################
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  CAUTION
&lt;/h5&gt;

&lt;p&gt;*The &lt;code&gt;VITE_&lt;/code&gt; prefix exposes environment variables client-side!&lt;/p&gt;

&lt;p&gt;🤫 Be careful not to expose any secrets! This is what we want for the 3 variables above, but be careful when adding more! And, make sure you add it to your &lt;code&gt;.gitignore\&lt;/code&gt;, if using git for source control and a public repo, if you add any sort of secrets to avoid accidentally publishing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;Install required packages with npm: *yarn v2+ may cause some strange and seemingly unrelated errors when trying to run the app. It's currently being investigated. It's suggested to use &lt;code&gt;npm\&lt;/code&gt; for now&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the App
&lt;/h2&gt;

&lt;p&gt;Start the dev server as you would with any Vite React app by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your browser, navigate to &lt;code&gt;http://localhost:5173&lt;/code&gt;* &lt;br&gt;
*or the url printed by Vite once running&lt;/p&gt;

&lt;h2&gt;
  
  
  If Everything Goes Smoothly 🤞
&lt;/h2&gt;

&lt;p&gt;Vite + React + Frontegg&lt;/p&gt;

&lt;p&gt;You should see the vite React template...  &lt;em&gt;plus a little more&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When you open your running app in the browser, you should land on a page that looks like the gif at the top of this readme, i.e., the Vite React template PLUS some Frontegg parts like the logo and &lt;code&gt;login&lt;/code&gt; button.&lt;/p&gt;

&lt;p&gt;*If you need help creating a Frontegg &lt;strong&gt;Account&lt;/strong&gt; with a &lt;strong&gt;User&lt;/strong&gt; with the &lt;strong&gt;Application&lt;/strong&gt; assigned, check out the next section for help!&lt;/p&gt;

&lt;p&gt;Clicking on the &lt;code&gt;login&lt;/code&gt; button should bring you to your login page, customizable via the &lt;a href="https://developers.frontegg.com/guides/login-box/intro" rel="noopener noreferrer"&gt;Login Box Builder&lt;/a&gt; in the admin portal.&lt;/p&gt;

&lt;p&gt;After successfully logging in, you should be redirected back to the original page with the &lt;code&gt;login&lt;/code&gt; button replaced with a &lt;code&gt;logout&lt;/code&gt; button and the logged in user's email displayed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trying it Out
&lt;/h2&gt;

&lt;p&gt;To test it out (a.k.a. to try logging in), you'll need an &lt;strong&gt;Account&lt;/strong&gt; with a &lt;strong&gt;User&lt;/strong&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Create an 'Account'
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Under &lt;code&gt;Management&lt;/code&gt; &amp;gt; &lt;code&gt;Accounts&lt;/code&gt; in the dashboard, create a new &lt;a href="https://developers.frontegg.com/guides/management/manage-accounts/overview" rel="noopener noreferrer"&gt;Account&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Open your newly created &lt;code&gt;Account&lt;/code&gt; and click on the &lt;code&gt;Applications&lt;/code&gt; tab.&lt;/li&gt;
&lt;li&gt;If you don't see your Application here:

&lt;ol&gt;
&lt;li&gt;Click on &lt;code&gt;Assign applications&lt;/code&gt; to allow users in this &lt;strong&gt;Account&lt;/strong&gt; to authenticate via your &lt;strong&gt;Application&lt;/strong&gt;.&lt;a href="https://developers.frontegg.com/guides/management/multi-apps/apps-accounts-management" rel="noopener noreferrer"&gt;1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select the Application configuration which you're using.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create a user:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Under &lt;code&gt;Management &amp;gt; Users&lt;/code&gt; (or on a specific &lt;strong&gt;Account's&lt;/strong&gt; page under the &lt;code&gt;Users&lt;/code&gt; tab), click the &lt;code&gt;Create user&lt;/code&gt; button.&lt;a href="https://developers.frontegg.com/guides/management/multi-apps/apps-users-management" rel="noopener noreferrer"&gt;2&lt;/a&gt;

&lt;ol&gt;
&lt;li&gt;Make sure your app is added to the list of Applications in the create user modal. It needs to be assigned to this Account first, though, otherwise it won't be available to select.&lt;/li&gt;
&lt;li&gt;And, if you started from the &lt;code&gt;Users&lt;/code&gt; page, make sure you add the &lt;strong&gt;Account&lt;/strong&gt; you're using to the list in the modal.

&lt;ol&gt;
&lt;li&gt;Starting from the &lt;code&gt;Users&lt;/code&gt; tab of a specific &lt;strong&gt;Account&lt;/strong&gt; connects the user to that &lt;strong&gt;Account&lt;/strong&gt; right away.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Inviting by email provides an easy way to start testing. Once you've successfully created the user, you'll receive a link to the corresponding email to activate the account.&lt;a href="https://developers.frontegg.com/guides/management/manage-users/user-invitation" rel="noopener noreferrer"&gt;3&lt;/a&gt;
&lt;/li&gt;

&lt;/ol&gt;

&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  Run the app and login
&lt;/h3&gt;

&lt;p&gt;Run the app (e.g., &lt;code&gt;npm run dev&lt;/code&gt;) and open the app in a browser where you should see a page with the three logos and some stuff below (gif shown at the top).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Clicking the login button should redirect you to your Frontegg login page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is what's referred to as the "Hosted Login" (as opposed to the "Embedded Login"&lt;a href="https://developers.frontegg.com/guides/env-settings/hosted-embedded" rel="noopener noreferrer"&gt;4&lt;/a&gt;). You can change the UI using the "Login Builder" found in the dashboard.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;After successfully authenticating, you should be brought back to the app (localhost:5173 in dev mode),&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With a small difference indicating you've logged in!&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Login&lt;/code&gt; button should be replaced with a &lt;code&gt;Logout&lt;/code&gt; button and the email of the user you just authenticated with.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to do in case...
&lt;/h2&gt;

&lt;h3&gt;
  
  
  First Debug Steps
&lt;/h3&gt;

&lt;p&gt;There are a lot of different values that are usually mostly random strings used in a lot of different places, so it's easy to accidentally use the wrong value for several reasons.&lt;/p&gt;

&lt;p&gt;Double check the following are match between your code and what's in the Frontegg dashboard:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Environment Variables&lt;/li&gt;
&lt;li&gt;App URL&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;redirect_uri&lt;/code&gt; (more below)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;redirect_uri&lt;/code&gt; not found
&lt;/h3&gt;

&lt;p&gt;Hit the dreaded &lt;code&gt;redirect_uri&lt;/code&gt; not found error? Don't worry, everyone using OAuth 2/OIDC hits at some point. I can't seem to get enough of it. But, it's an important part of how the security of  &lt;a href="https://datatracker.ietf.org/doc/html/rfc6749" rel="noopener noreferrer"&gt;OAuth 2&lt;/a&gt;, and therefore &lt;a href="https://openid.net/specs/openid-connect-core-1_0.html" rel="noopener noreferrer"&gt;OIDC&lt;/a&gt; (OIDC is a layer built on top of OAuth 2), works&lt;/p&gt;

&lt;p&gt;First, check that everything looks as expected from the step above in the &lt;code&gt;Configuring Frontegg&lt;/code&gt; section: &lt;em&gt;Don't forget to add your &lt;code&gt;redirect_uri&lt;/code&gt;!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  User is not associated with the requested application
&lt;/h3&gt;

&lt;p&gt;This means the User you tried signing in with belongs to an Account which doesn't have the Application linked. In other words, the Application with the corresponding App ID you used for the &lt;code&gt;Client ID&lt;/code&gt; in the environment variables needs to be assigned to an Account which the User belongs to. If you're user does belong to an Account where the Application is linked. Find the User and open the context menu (3 dots at the end of the User's row) and click &lt;code&gt;Edit applications&lt;/code&gt; and assign the corresponding Application. This can happen if the Application is assigned to the Account &lt;em&gt;after&lt;/em&gt; the User was already added there.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Info
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Minimal React Sample
&lt;/h3&gt;

&lt;p&gt;To help make it easier to focus on the pieces relevant for integrating Frontegg, this sample app is simply the Vite React (Typescript) Template with a few additions. &lt;a href="https://vite.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;The Vite.dev docs&lt;/a&gt; are a great place to start if you want to learn more about the surrounding "non-Frontegg" pieces.&lt;/p&gt;

&lt;h4&gt;
  
  
  Goal
&lt;/h4&gt;

&lt;p&gt;The goal of this article and the accompanying sample app is to remove everything that’s not necessary to start exploring or evaluating Frontegg in an actual app, an app that you can test with, play with, share, blow up, and maybe (hopefully?) learn from.&lt;/p&gt;

&lt;h4&gt;
  
  
  What to Expect
&lt;/h4&gt;

&lt;p&gt;Following the guide here or the one in the &lt;a href="https://github.com/akdombrowski/frontegg-vite-react-ts/?tab=readme-ov-file#readme" rel="noopener noreferrer"&gt;repo's README&lt;/a&gt; to learn how to integrate Frontegg into a React app. And, since it makes use of the cloud-hosted login page (Frontegg also provides an “embedded” option for maximal control), you, or someone you invite, can make changes from the Frontegg dashboard and have them immediately reflect in the app without you touching any bit of code.&lt;/p&gt;

&lt;h4&gt;
  
  
  The starting point
&lt;/h4&gt;

&lt;p&gt;Is the &lt;a href="https://vite.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;Vite React with Typescript template&lt;/a&gt; app. capabilities it makes up for in you over that first blocker to seeing the possibilities of what you can accomplish with Frontegg’s platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The necessary dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontegg React SDK

&lt;ol&gt;
&lt;li&gt;@frontegg/react&lt;/li&gt;
&lt;li&gt;Recommended to use npm at it is tested and while some kinks are being worked out with compatibility with yarn v2+&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;React Router

&lt;ol&gt;
&lt;li&gt;react-router-dom&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Import the Frontegg Context and Components:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import the necessary components from the Frontegg React SDK into your React application. This typically includes a context provider and hooks for accessing authentication state and functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Wrap Your Application with the Frontegg Provider:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wrap your root React component with the Frontegg provider component. This will make the authentication context available throughout your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Configure the Frontegg Provider:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pass your Frontegg application ID and other relevant configuration options to the Frontegg provider component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Add Login and Logout Functionality:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the login and logout functions provided by the Frontegg hooks to add login and logout buttons or links to your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Protect Routes and Components:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the authentication state provided by the Frontegg hooks to conditionally render routes or components based on whether the user is logged in or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Display or Utilize User Information:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the user object provided by the Frontegg hooks to display the user's name, email, or other relevant information in your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;9. Customize the User Interface:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontegg often provides customizable UI components for login, registration, and profile management. Use these components or build your own to match the design of your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;10. Consider Advanced Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explore advanced features provided by Frontegg, such as social logins, multi-factor authentication, role-based access control, and audit logs. These features can enhance the security and functionality of your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Points and Benefits of using Frontegg for Authentication in your client-side React App
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplifies Authentication:&lt;/strong&gt; Frontegg handles the complexities of authentication, allowing you to focus on building your application's core features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-Built UI Components:&lt;/strong&gt; Frontegg often provides pre-built UI components for login, registration, and self-service management, saving you development time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customization:&lt;/strong&gt; Frontegg allows you to customize the UI and behavior of the authentication flow to match your application's design and requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Frontegg implements security best practices to protect your application and user data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Frontegg's cloud-based infrastructure can handle the authentication needs of applications of all sizes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;Drop any questions in the comments!&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontegg
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developers.frontegg.com/sdks/frontend/react/hosted-login" rel="noopener noreferrer"&gt;@frontegg/react Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@frontegg/react" rel="noopener noreferrer"&gt;@frontegg/react on npm&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developers.frontegg.com/guides/login-box/intro" rel="noopener noreferrer"&gt;Frontegg's Hosted Login Page Intro&lt;/a&gt;&lt;br&gt;
&lt;a href="https://portal.frontegg.com/signup" rel="noopener noreferrer"&gt;Free Trial Signup&lt;/a&gt;&lt;br&gt;
&lt;a href="https://join.slack.com/t/frontegg-community/shared_invite/zt-e1oxi1vn-SZErBZcwHcbgj4vrwRIp5A" rel="noopener noreferrer"&gt;Slack Channel&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/frontegg" rel="noopener noreferrer"&gt;Frontegg on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Vite
&lt;/h3&gt;

&lt;p&gt;To help make it easier to focus on the pieces relevant for integrating Frontegg, this sample app is simply the Vite React (Typescript) Template with a few additions. &lt;a href="https://vite.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;The Vite.dev docs&lt;/a&gt; are a great place to start if you want to learn more about the surrounding "non-Frontegg" pieces.&lt;/p&gt;

&lt;h3&gt;
  
  
  Other
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://openid.net/developers/how-connect-works/" rel="noopener noreferrer"&gt;What is OpenID Connect&lt;/a&gt;&lt;/p&gt;

</description>
      <category>authentication</category>
      <category>security</category>
      <category>react</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
