mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
confirmed SSR support with Remix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { notifications } from "@mantine/notifications";
|
||||
//import { notifications } from "@mantine/notifications";
|
||||
import { getDefaultConfig, getDefaultSchema } from "modules/ModuleManager";
|
||||
import { createContext, startTransition, useContext, useEffect, useRef, useState } from "react";
|
||||
import type { ModuleConfigs, ModuleSchemas } from "../../modules";
|
||||
@@ -83,7 +83,6 @@ export function BkndProvider({
|
||||
|
||||
if (!fetched || !schema) return null;
|
||||
const app = new AppReduced(schema?.config as any);
|
||||
|
||||
const actions = getSchemaActions({ client, setSchema, reloadSchema });
|
||||
|
||||
return (
|
||||
@@ -93,6 +92,20 @@ export function BkndProvider({
|
||||
);
|
||||
}
|
||||
|
||||
type BkndWindowContext = {
|
||||
user?: object;
|
||||
logout_route: string;
|
||||
};
|
||||
export function useBkndWindowContext(): BkndWindowContext {
|
||||
if (typeof window !== "undefined" && window.__BKND__) {
|
||||
return window.__BKND__ as any;
|
||||
} else {
|
||||
return {
|
||||
logout_route: "/api/auth/logout"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function useBknd({ withSecrets }: { withSecrets?: boolean } = {}): BkndContext {
|
||||
const ctx = useContext(BkndContext);
|
||||
if (withSecrets) ctx.requireSecrets();
|
||||
|
||||
Reference in New Issue
Block a user