Refactor PocketBase client initialization, update HTML template for favicon handling, and remove redundant text in main components for improved clarity and performance in SvelteKit project.
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m39s

This commit is contained in:
eewing
2026-02-17 15:30:31 -06:00
parent 7269444163
commit 27f297f9ec
6 changed files with 28 additions and 8 deletions
+21 -1
View File
@@ -2,4 +2,24 @@ import PocketBase from "pocketbase";
const POCKETBASE_URL = "https://pocketbase.ccllc.pro";
export const pb = new PocketBase(POCKETBASE_URL);
/** Base URL for API/file URLs; safe to use during SSR. */
export const POCKETBASE_BASE_URL = POCKETBASE_URL;
let _pb: PocketBase | null = null;
/** PocketBase client — only created in the browser to avoid fetch during SSR. */
export function getPb(): PocketBase {
if (typeof window === "undefined") {
throw new Error("PocketBase client is only available in the browser. Use load/actions for server data.");
}
if (!_pb) _pb = new PocketBase(POCKETBASE_URL);
return _pb;
}
/** Lazy client proxy: baseUrl is safe during SSR; other access creates the client in the browser only. */
export const pb = new Proxy({} as PocketBase, {
get(_, prop) {
if (prop === "baseUrl") return POCKETBASE_BASE_URL;
return (getPb() as Record<string, unknown>)[prop as string];
},
});