@serwist/next
Version:
A module that integrates Serwist into your Next.js application.
17 lines (13 loc) • 441 B
text/typescript
import type { Serwist } from "@serwist/window";
import { createContext, useContext } from "react";
export interface SerwistContextValues {
serwist: Serwist | null;
}
export const SerwistContext = createContext<SerwistContextValues>(null!);
export const useSerwist = () => {
const context = useContext(SerwistContext);
if (!context) {
throw new Error("[useSerwist]: 'SerwistContext' is not available.");
}
return context;
};