Next.js Discord

Discord Forum

revalidate nextjs cache help

Answered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
Im running this function in a form submission:
    const handleSubmit = async (values: typeof form.values) => {
        await updateUserName({
            user_id,
            username: values.name,
        })
            .then(() => {
                notifications.show({
                    message: `Updated username to ${values.name}!`,
                });
            })
            .catch(() =>
                notifications.show({
                    color: 'red',
                    message: `There was a problem updating your username. Please try again later.`,
                })
            );

        form.reset();

        revalidatePath('/profile/me');
    };

However, the revalidatePath function is not being called in my client component? Why not
Answered by Ray
Because the data cache is on the server, client wont be able to access it. Therefore, revalidatePath should be used on server side.
You should use server action for the form submission
View full answer

3 Replies