Next.js Discord

Discord Forum

tanstack-query Next Js not updating the data in Production

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
My app work fine in localhost, if i update the data it shows the update quickyly. But after deploying it doesnt refetch the newest data. It only get the new data after redeploying it.

If i have update the data in deplpyed app it reflects on the localhost just only in production.

3 Replies

Giant Angora
hi angelo ? i have the same issue in next.js 15 , you found the solution for it ?
are you guys using the query client to invalidate the cache?
export const useAddBlog = () => {
    const queryClient = useQueryClient();
    return useMutation({
        mutationFn: (formData: FormData) => {
            return addBlog(formData);
        },
        onSuccess: () => {
            queryClient.invalidateQueries({ queryKey: ['blogs', false, 1], });
        },
        onError: (error) => {
            console.error('Mutation error:', error);
        }
    });
};