Refresh Page From Server Component
Answered
Cape lion posted this in #help-forum
Cape lionOP
How can I reload a page after a server action from a server (non-client) component?
Answered by Cape lion
Hmm it seems like you can use
redirect('/') from next/navigation12 Replies
Cape lionOP
Hmm it seems like you can use
redirect('/') from next/navigationAnswer
@Cape lion How can I reload a page after a server action from a server (non-client) component?
Giant panda
i thought the server actions revalidate themselves
i assume thats what you want?
or i think you have to invalidate it on the route and then it'll cause revalidation immediately after
Cape lionOP
I thought so too but it doesn't seem that way on testing
you can use router.refresh()
Cape lionOP
router only works on client components according to docs and the error I get when I try to use it in the server component
Ant
what about "revalidatePath" ?
@Ant what about "revalidatePath" ?
Giant panda
that's the one
i think
I know I'd used that and it actually revalidated
@Cape lion I thought so too but it doesn't seem that way on testing
Giant panda
well i really hope they make it so its automatic