mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
21 lines
702 B
TypeScript
21 lines
702 B
TypeScript
import { withApi } from "bknd/adapter/nextjs";
|
|
import type { BkndAdminProps } from "bknd/ui";
|
|
import type { InferGetServerSidePropsType } from "next";
|
|
import dynamic from "next/dynamic";
|
|
|
|
export const getServerSideProps = withApi(async (context) => {
|
|
return {
|
|
props: {
|
|
user: context.api.getUser()
|
|
}
|
|
};
|
|
});
|
|
|
|
export function adminPage(adminProps?: BkndAdminProps) {
|
|
const Admin = dynamic(() => import("bknd/ui").then((mod) => mod.Admin), { ssr: false });
|
|
return (props: InferGetServerSidePropsType<typeof getServerSideProps>) => {
|
|
if (typeof document === "undefined") return null;
|
|
return <Admin withProvider={{ user: props.user }} {...adminProps} />;
|
|
};
|
|
}
|