Skip to content

Authenticate your ZITADEL users within your react applications

Notifications You must be signed in to change notification settings

zitadel/zitadel-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@zitadel/react Example

Authenticate your ZITADEL users within your React applications.

Important

If you want to try out @zitadel/react, read the ZITADEL step-by-step guide for React. It shows how to get the authority and client_id from ZITADEL and how to wire everything up in React.

Project Structure

This project is a default React application created with Create React App that contains the ZITADEL React SDK to handle OIDC. The library is located in /lib folder and published as @zitadel/react.

NPM Version NPM License PRs Welcome

The following pages are added to the scaffolded example application:

  • src/components/Login.tsx: The login page shows a button if no user is authenticated and redirects the user to /callback if authenticated.
  • src/components/Callback.tsx: This page completes the auth flow and renders the retrieved information from the user info endpoint.

Run

To run the example, navigate to the /lib folder and run yarn build.

cd /lib
yarn install
yarn build

then navigate back and install the dependencies of the example application

cd ..
yarn install

Next follow the guide for React applications in our docs and set authority as well as client_id in the App.tsx file. Finally you can start the application with

yarn start

Your application will then run on http://localhost:3000.

Available scripts

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.