How to fire a client side event on sign-in with nextAuth?
Unanswered
Barbary Lion posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Barbary LionOP
I want to fire an event when a user signs in on the client side. Currently i can do it for new users cause they land on a welcome page. When a user signs in normally I increment user.logins on the server side and take them to their dashboard. Is there a good way to know if it's a new sign so i can fire a client side event?
11 Replies
![Avatar](https://cdn.discordapp.com/avatars/414145877335080960/c7ab639b9f825e9f8db0ed902b831f2b.webp?size=256)
linesofcode
Cookies
Set a cookie if it’s a new sign in, then check for this cookie
You have access to req object in next auth
Also you can use middleware for that redirect after doing the cookie check
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Barbary LionOP
interesting, thank you @linesofcode
can you explain the middleware approach?
why do i want to redirect?
![Avatar](https://cdn.discordapp.com/avatars/414145877335080960/c7ab639b9f825e9f8db0ed902b831f2b.webp?size=256)
linesofcode
if you want to show a differnt page for example for the first signed in users
vs users who have already signed in multiple times
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Barbary LionOP
for first signed in users this isn't needed
nextAuth config has a
pages :{ newUser: path }