Simple redirect in server action not working
Unanswered
Flammulated Owl posted this in #help-forum
Flammulated OwlOP
<Button
className="w-full bg-yellow-400 text-black"
onClick={async () => {
await signOutAction()
}}
>
<LogOut className="mr-2 h-4 w-4" />
Logout
</Button>
'use server'
import { revalidatePath } from 'next/cache'
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
export async function signOutAction() {
redirect('/seminar')
}
The page just flashes and no redirect happens
2 Replies
Can you try wrapping the Server Action call in startTransition?
Wool sower gall maker
Or put the redirect on the client side, in the onClick