miniperplx/app/providers.tsx
simplr-sh 186bd3c2cc Refactor environment variable handling and improve API key management
- Introduced `client.ts` and `server.ts` for structured environment variable management using `@t3-oss/env-nextjs`.
- Updated references to environment variables in various files to use the new `clientEnv` and `serverEnv` objects.
- Enhanced the `next.config.mjs` file to validate environment variables during build.
- Added new dependencies: `@t3-oss/env-nextjs` and `jiti` for improved environment handling.
- Cleaned up imports and ensured consistent usage of environment variables across the application.
2025-01-06 10:28:54 +05:30

29 lines
730 B
TypeScript

"use client";
import { clientEnv } from "@/env/client";
import { ThemeProvider } from "next-themes";
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';
import { ReactNode } from "react";
if (typeof window !== 'undefined') {
posthog.init(clientEnv.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: clientEnv.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: 'always',
})
}
export function Providers({ children }: { children: ReactNode }) {
return (
<PostHogProvider client={posthog}>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</PostHogProvider>
)
}