Course lesson

Refresh Data with Next.js revalidatePath when submitting a Server Action

When you create data, you want to see that data reflected in your UI as quickly as possible. In our previous implementation we were doing that with react-query by invalidating it's cache so it would fetch customers again.

Duration
1 min
Access
Free
Transcript
Needs source

When you create data, you want to see that data reflected in your UI as quickly as possible. In our previous implementation we were doing that with react-query by invalidating it's cache so it would fetch customers again.

Using the revalidatePath function from next/cache in combination with our server action we can add a customer and see the must up-to-date data