@usedetach/hydrogen
v0.2.1
Published
Hydrogen / React Router integration for Detach — loader helpers, preview cookies, sub-request content cache.
Downloads
511
Readme
@usedetach/hydrogen
Hydrogen / React Router integration for
Detach. Web-standard
Request/Response/Headers only — no Oxygen globals, no Node APIs — so it runs wherever Hydrogen
does.
npm install @usedetach/hydrogen// app/routes/$handle.tsx
import { loadCmsPage } from "@usedetach/hydrogen";
export async function loader({ request, params }) {
const { page, preview } = await loadCmsPage(
cms,
request,
{ handle: params.handle },
contentCache,
);
return { page, preview };
}revalidateTag does not exist off Vercel, so cache invalidation is explicit here:
createContentCache is a stale-while-revalidate sub-request cache keyed on the environment's
publication_version, invalidated by publish webhooks through createRevalidateHandler and
self-healing when a version bump arrives on any response.
Also here: createPreviewRouteHandler, getPreviewSession, loadCmsGlobals, loadCmsAudiences,
resolveCmsTemplate, getVisitorContext, and the cacheApiAdapter / memoryCacheAdapter backends.
Requires @usedetach/core. Render content with @usedetach/react.
