Next.js Discord

Discord Forum

login->serveraction->update state

Answered
Dutch posted this in #help-forum
Open in Discord
DutchOP
Sorry for long text, I promise its a really simple situation just hard to say in few words ^^

I have basically a page with a component that takes in state_a and state_b. upon mount, this component animates in from state_a to state_b. The user then logs in, using a form which triggers a server action which does the login. on successfull login, I want to now reload the page but with state_a and state_b being different (basically state_a beoming the old state_b and state_b being the next part of the stepper so the user can do the next thing he needs to do after logging in).

How can I best do this? I know i can probably do it by setting the redirect in the action to include some parameters that I can then extract on the loading of the page to give the new state_a and state_b but is there any other way? seems annoying to have those extra things in the url all of a sudden.
Answered by James4u
if you don't like query params in the url, what about cookie?
View full answer

8 Replies

if you don't like query params in the url, what about cookie?
Answer
@Dutch
but I can't imagine what you are gonna do, right after login, user stays in the same page? with only different animation?
DutchOP
well I have a stepper and one of the steps is login, then when the login is done the stepper animates to the next step and the content changes from the login form to the next thing
so I need to give some information back to the page and the stepper which is a client component
it seems query params are a common choice, so thats what I ended up doing and it works out fine so far
cookies also a good idea, ive not needed to directly interact with them sofar tho and search params seems easier ^^
@James4u if you don't like query params in the url, what about cookie?
DutchOP
but I suppose this was the alternative I was looking for, there's probably not many other options, so ty :)