client config via .env file

This commit is contained in:
2025-11-29 16:46:56 +05:30
parent d4edf049ed
commit ecb8825734
2 changed files with 8 additions and 2 deletions

View File

@@ -47,7 +47,11 @@ export const NakamaContext = createContext<NakamaContextType>(null!);
export function NakamaProvider({ children }: { children: React.ReactNode }) {
const [client] = useState(
() => new Client("defaultkey", "127.0.0.1", "7350")
() => new Client(
import.meta.env.VITE_WS_SKEY,
import.meta.env.VITE_WS_HOST,
import.meta.env.VITE_WS_PORT
)
);
const [session, setSession] = useState<Session | null>(null);

4
src/vite-env.d.ts vendored
View File

@@ -1,7 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_WS_BASE_URL: string;
readonly VITE_WS_HOST: string;
readonly VITE_WS_PORT: string;
readonly VITE_WS_SKEY: string;
}
interface ImportMeta {