Implementing a central authentication context

We are going to implement a context that contains state and functions for authentication that we'll provide to all of the components in our app. Let's carry out the following steps:

  1. Create a new file in the src folder called Auth.tsx with the following import statements:
import React, {  useState,  useEffect,  useContext,  createContext,  FC,} from 'react';import createAuth0Client from '@auth0/auth0-spa-js';import Auth0Client from '@auth0/auth0-spa-js/dist/typings/Auth0Client';import { authSettings } from './AppSettings';
  1. We'll start the implementation by creating a context that our app components will use to get access to authentication-related information and functions:
interface Auth0User { ...

Get ASP.NET Core 3 and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.