https://supertokens.com/ logo
a

Astro

04/03/2022, 9:41 PM
Does anyone know why
const {userId} = useSessionContext();
would return
DEFAULT_USER_ID
?
r

rp

04/04/2022, 4:06 AM
Yes. You need to wrap the component with the auth wrapper that we have.
a

Astro

04/04/2022, 5:44 AM
Could you point me to that part of the docs please? Thanks
a

Astro

04/04/2022, 6:03 AM
Thanks mate much appreciated
r

rp

04/04/2022, 6:04 AM
thats for thirdpartyemailpassword recipe. If you are using another recipe, please navigate to that recipe's docs instead
there should be a similar section in the other recipe docs
a

Astro

04/04/2022, 6:04 AM
Ah so that is in place
It was working as I said, itโ€™s in my app tsx along with my routing set up. Will double check later today though
r

rp

04/04/2022, 6:06 AM
sounds good!
a

Astro

04/04/2022, 8:01 AM
so this is how i have it set up:
Copy code
html
 <Route path="/" element={
   <ThirdPartyEmailPasswordAuth>
     <Context.Provider value={{
         todos: todos ?? []
      }}>
        <Header />
        <TodoList />
      </Context.Provider>
    </ThirdPartyEmailPasswordAuth>
 } />
oh dear, that indentation came out wonky
r

rp

04/04/2022, 8:04 AM
That should work.
If you are using
ThirdPartyEmailPassword
recipe.
a

Astro

04/04/2022, 8:04 AM
yeah it's weird, it was, then all of a sudden wasn't
r

rp

04/04/2022, 8:04 AM
is it still not working?
a

Astro

04/04/2022, 8:04 AM
obviously something changed but I can't work out what it is
nah, still not working
r

rp

04/04/2022, 8:05 AM
In which component are you using
useSessionContext
?
In the
TodoList
?
a

Astro

04/04/2022, 8:05 AM
wait
thank you!
I reworked the app to use context rather than props and that meant moving my authenticated api calls upwards
so at the moment the component where I make api calls isn't wrapped
that must be it?
r

rp

04/04/2022, 8:07 AM
You can wrap your whole app with:
Copy code
import {SessionAuth} from "supertokens-auth-react/recipe/session"

<SessionAuth requireAuth={false}>
  <App />
</SessionAuth>
And this way, the
useSessionContext
can be used anywhere in your app
a

Astro

04/04/2022, 8:07 AM
Sweet, I'll do that. Thank you very much for your time
r

rp

04/04/2022, 8:07 AM
(As long as the app is client side rendered)
a

Astro

04/04/2022, 8:07 AM
it is ๐Ÿ˜„
3 Views