@@ -11,7 +11,8 @@ in React.
1111## Prerequisites
1212
13131 . Create a SpacetimeAuth project and configure a client as described in the
14- [ Getting Started] ( ./create-project.md ) and [ Configuration] ( ./configure-project.md ) guides.
14+ [ Getting Started] ( /docs/spacetimeauth/create-project ) and
15+ [ Configuration] ( /docs/spacetimeauth/configure-project ) guides.
15162 . Have a React application set up. You can use Create React App or any other
1617 React framework.
17183 . Install the ` react-oidc-context ` package in your React application:
@@ -24,8 +25,7 @@ Create an OIDC configuration object with your SpacetimeAuth project details.
2425Make sure to replace ` YOUR_CLIENT_ID ` with the actual client ID from your
2526SpacetimeAuth dashboard.
2627
27- ``` javascript
28- // src/index.tsx
28+ ``` tsx
2929const oidcConfig = {
3030 authority: ' https://spacetimeauth.staging.spacetimedb.com/oidc' ,
3131 client_id: ' YOUR_CLIENT_ID' ,
@@ -41,19 +41,22 @@ const oidcConfig = {
4141This component will log various authentication events and state changes to
4242the console for debugging purposes.
4343
44- ``` javascript
44+ ``` tsx
4545export function OidcDebug() {
4646 const auth = useAuth ();
4747
4848 useEffect (() => {
4949 const ev = auth .events ;
5050
51- const onUserLoaded = (u : any ) => console .log (" [OIDC] userLoaded" , u? .profile ? .sub , u);
52- const onUserUnloaded = () => console .log (" [OIDC] userUnloaded" );
53- const onAccessTokenExpiring = () => console .log (" [OIDC] accessTokenExpiring" );
54- const onAccessTokenExpired = () => console .log (" [OIDC] accessTokenExpired" );
55- const onSilentRenewError = (e : any ) => console .warn (" [OIDC] silentRenewError" , e);
56- const onUserSignedOut = () => console .log (" [OIDC] userSignedOut" );
51+ const onUserLoaded = (u : any ) =>
52+ console .log (' [OIDC] userLoaded' , u ?.profile ?.sub , u );
53+ const onUserUnloaded = () => console .log (' [OIDC] userUnloaded' );
54+ const onAccessTokenExpiring = () =>
55+ console .log (' [OIDC] accessTokenExpiring' );
56+ const onAccessTokenExpired = () => console .log (' [OIDC] accessTokenExpired' );
57+ const onSilentRenewError = (e : any ) =>
58+ console .warn (' [OIDC] silentRenewError' , e );
59+ const onUserSignedOut = () => console .log (' [OIDC] userSignedOut' );
5760
5861 ev .addUserLoaded (onUserLoaded );
5962 ev .addUserUnloaded (onUserUnloaded );
@@ -73,14 +76,20 @@ export function OidcDebug() {
7376 }, [auth .events ]);
7477
7578 useEffect (() => {
76- console .log (" [OIDC] state" , {
79+ console .log (' [OIDC] state' , {
7780 isLoading: auth .isLoading ,
7881 isAuthenticated: auth .isAuthenticated ,
7982 error: auth .error ?.message ,
8083 activeNavigator: auth .activeNavigator ,
8184 user: !! auth .user ,
8285 });
83- }, [auth .isLoading , auth .isAuthenticated , auth .error , auth .activeNavigator , auth .user ]);
86+ }, [
87+ auth .isLoading ,
88+ auth .isAuthenticated ,
89+ auth .error ,
90+ auth .activeNavigator ,
91+ auth .user ,
92+ ]);
8493
8594 return null ;
8695}
@@ -91,7 +100,7 @@ export function OidcDebug() {
91100Wrap your React application with the ` AuthProvider ` component to provide
92101authentication context.
93102
94- ` ` ` javascript
103+ ``` tsx
95104import React from ' react' ;
96105import ReactDOM from ' react-dom/client' ;
97106import { AuthProvider , useAuth } from ' react-oidc-context' ;
0 commit comments