# React SPA w/ express server - on login give express user\_id

**URL:** <https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279>\
**Category:** Get Help\
**Created:** [March 30, 2021, 12:17am UTC](https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279 "2021-03-30T00:17:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kiro/32/15194_2.png) [@kiro](https://community.auth0.com/u/kiro)\
**Post date:** [March 30, 2021, 12:17am UTC](https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279/1 "2021-03-30T00:17:36Z")

</div>

I have a database that i’m storing the auth0 user\_id in, and when a user logs into the web app, it would be great to check to see if that user\_id exists in the database table.

to do that it seems like express needs the token on login, but the SPA seems to handle the authentication flow, and does not engage the express api until there is an explicit http request that passes the token to the server that engages with checkJwt.

does anyone have any good ideas about how to get the user\_id to the server as soon as the user logs in?

i’m wrapping the `<Auth0ProviderWithHistory>` around my `<App>` approach.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 31, 2021, 7:51pm UTC](https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279/3 "2021-03-31T19:51:27Z")

</div>

Hi @kiro,

You could handle the `user_id` update in a [rule](https://auth0.com/docs/rules) instead of in your SPA. Rules execute after authentication, so you could send the user ID to your API at that point before redirecting to your React app. You can call your own API by following this FAQ:

[https://community.auth0.com/t/how-do-i-call-my-api-from-a-rule/41309](https://community.auth0.com/t/how-do-i-call-my-api-from-a-rule/41309)

---

<div class="post-metadata">

**Author:** ![kiro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kiro/32/15194_2.png) [@kiro](https://community.auth0.com/u/kiro)\
**Post date:** [March 31, 2021, 9:41pm UTC](https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279/4 "2021-03-31T21:41:25Z")

</div>

these are the droids. 🙃

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 15, 2021, 9:42pm UTC](https://community.auth0.com/t/react-spa-w-express-server-on-login-give-express-user-id/60279/5 "2021-04-15T21:42:13Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
