Is react cache supported?

Hi, I'm developing in nextjs and deploying on cloudflare pages. Recently I'm exploring ways to move net requests to the server side to make client side simpler. One challenge is to cache the requests on server side. I learned that react has cache support like this:
import { SupabaseClient } from '@supabase/supabase-js';
import { cache } from 'react';

export const getUser = cache(async (supabase: SupabaseClient) => {
const {
data: { user }
} = await supabase.auth.getUser();
return user;
});
import { SupabaseClient } from '@supabase/supabase-js';
import { cache } from 'react';

export const getUser = cache(async (supabase: SupabaseClient) => {
const {
data: { user }
} = await supabase.auth.getUser();
return user;
});
I found some related docs https://developers.cloudflare.com/pages/framework-guides/nextjs/ssr/caching/ but it seems to be about fetch() calls. Does it work for react cache too?
Cloudflare Docs
Caching | Cloudflare Pages docs
@cloudflare/next-on-pages supports caching and revalidating data returned by subrequests you make in your app by calling fetch().
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server