fixing imports and ssr support + updated remix/nextjs/astro examples

This commit is contained in:
dswbx
2024-12-07 19:31:12 +01:00
parent 94cc4042d3
commit 3932396084
40 changed files with 125 additions and 130 deletions

View File

@@ -1,7 +1,7 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { TApiUser } from "Api";
import { createContext, useContext, useEffect, useState } from "react";
import { useBkndWindowContext } from "ui/client/BkndProvider";
//import { useBkndWindowContext } from "ui/client/BkndProvider";
import { AppQueryClient } from "./utils/AppQueryClient";
const ClientContext = createContext<{ baseUrl: string; client: AppQueryClient }>({
@@ -89,3 +89,17 @@ export const useBaseUrl = () => {
const context = useContext(ClientContext);
return context.baseUrl;
};
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"
};
}
}