Skip to main content
Contributor I
June 29, 2026
Solved

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

  • June 29, 2026
  • 4 replies
  • 148 views

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?

 

Best answer by KeviSunshine

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.

4 replies

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
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.

ovidiumAuthor
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
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.