rwsdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
13 lines (12 loc) • 526 B
JavaScript
import { createServerReference as baseCreateServerReference } from "react-server-dom-webpack/client.browser";
export const createServerReference = (id, name, method, source = "action") => {
const fullId = id + "#" + name;
const proxy = baseCreateServerReference(fullId, (id, args) => {
return globalThis.__rsc_callServer(id, args, source, method);
});
// Attach metadata that hooks like useQuery can use
proxy.id = fullId;
proxy.method = method;
proxy.source = source;
return proxy;
};