Skip to main content
Question

What is the recommended flow for login/logout in React app

  • June 29, 2026
  • 4 replies
  • 59 views

Forum|alt.badge.img

We have the Klaviyo snippet integrated in our React app.
We identify the user when the login. 
Looking in the docs https://developers.klaviyo.com/en/docs/javascript_api we see no way of “resetting” the user when they logout.
What is the recommendation for this?

 

4 replies

Forum|alt.badge.img
  • Problem Solver I
  • June 29, 2026

What I believe you have to do in that situation is identify the user with a null Shopper ID whenever the user is logged out. 


KeviSunshine
Expert Problem Solver III
Forum|alt.badge.img+9
  • Expert Problem Solver III
  • June 29, 2026

Hey ​@ovidium,

What’s the purpose of resetting the user? What’re you trying to achieve by resetting them? I work with React apps (some with login/logout flows) and I’ve never thought of resetting them so just curious what you're trying to achieve.

 

All the best,

Kevin.


Forum|alt.badge.img
  • Author
  • Contributor I
  • July 1, 2026

hi ​@KeviSunshine use cases is the following:
 - user A logs into the app
 - user is identified in klaviyo, and may be shown a popup form for example
 - user logs out
 - the klaviyo snippet has user A identified and may show them a popup, even though they are logged out

Having a “forget user” that we could trigger on logout would prevent this
 


KeviSunshine
Expert Problem Solver III
Forum|alt.badge.img+9
  • Expert Problem Solver III
  • July 1, 2026

Hi ​@ovidium,

Ah, I see, that makes sense. I am not aware of any official “reset” API call or functionality that Klaviyo offers. However, check out this answer from ~1 year ago:

 

I would do some testing with removing the klaviyo cookie(s) and seeing how that works–that seems to be the best way to handle this.

There’s some talk about needing to refresh the page in that thread–I am skeptical as to whether that’s necessary. I would definitely try it out without that at first and see how it works.

 

Try it out and let us know!

Kevin.