mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
853610bbbf
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
804 B
TypeScript
26 lines
804 B
TypeScript
"use client";
|
|
|
|
import { useSyncExternalStore } from "react";
|
|
|
|
import { getRuntimeConfigClient } from "@/lib/get-runtime-config.client";
|
|
import {
|
|
EMPTY_RUNTIME_PUBLIC_CONFIG,
|
|
type RuntimePublicConfig,
|
|
} from "@/lib/runtime-config.shared";
|
|
|
|
// The island is browser-only, so SSR and the first hydration render must see
|
|
// the empty config to avoid a mismatch; useSyncExternalStore swaps to the
|
|
// island value afterwards. Both snapshots must be referentially stable.
|
|
const subscribe = () => () => {}; // config is immutable after load — never notifies
|
|
|
|
const getServerSnapshot = (): RuntimePublicConfig =>
|
|
EMPTY_RUNTIME_PUBLIC_CONFIG;
|
|
|
|
export function useRuntimeConfig(): RuntimePublicConfig {
|
|
return useSyncExternalStore(
|
|
subscribe,
|
|
getRuntimeConfigClient,
|
|
getServerSnapshot,
|
|
);
|
|
}
|