redirect issues
I have issues with redirect not working properly when called from a server actions , the account deletion work as intended but doesn't seems to work it just finish the task and remain on the same page what am I missing
am using app-router with drizzle-orm
4 Replies
server code looks right with this example:
https://nextjs.org/learn/dashboard-app/mutating-data#6-revalidate-and-redirect
I think client code needs to use a form action
However, in React, the action attribute is considered a special prop - meaning React builds on top of it to allow actions to be invoked.NOTE: I don't think there's any valid case for a submit button to have an
onClick
, as in your current code, except maybe analytics that tracks which submit button is used. Other actions are better off in the <form onSubmit={...}>
If that still doesn't work for some reason:
- does redirecting elsewhere work
- does console.log('foo'); redirect('/'); console.log('bar')
log boththe catch clause seems to be blocking the redirect I wonder why
ok I have just to put redirect outside of try catch block ty for help
ah yeah that sounds familiar.. something about
redirect
throwing an error that nextjs needs to catch
glad you found it!did it work? I read some where on github that intercepting routes has issue with navigation.