Next.js Discord

Discord Forum

server action redirect with startTransition possible?

Unanswered
Cuvier’s Dwarf Caiman posted this in #help-forum
Open in Discord
Cuvier’s Dwarf CaimanOP
How to redirect a server action with startTransition?

If I try to return redirect('/some/page') and my action is called using the startTransition method, I get the following on the server console:

error Error: NEXT_REDIRECT
    at getRedirectError 


And nothing happens in the app.

What I am trying to do, is I have rendered a list of data, and my "server action" would be to "select one" and use that list item data to create something. It seems odd to use a form and a different formAction per item? But is that the right way to go? Am I doing this all wrong?

On another note I just want to vent my frustration trying to find the right answer in the docs, it reminds me of trying to find Angular 2 vs. AngularJS when searching for problems. Also the docs seem to cut out important things like, where the hell do I import redirect or revalidatePath from? My IDE offers a few different spots.

Additionally, the docs show that the action is returned to the startTransition callback, where typescript doesn't like it as it wants a void callback:

... is not assignable to type 'VoidOrUndefinedOnly'

0 Replies