How to use PostHog with next.js, getting errors in provider
Answered
Chinese softshell turtle posted this in #help-forum
Chinese softshell turtleOP
get this error
on this code
I don't get why, it's from official docs of vercel
https://vercel.com/guides/posthog-nextjs-vercel-feature-flags-analytics
on this code
"use client"
import posthog from "posthog-js"
import { PostHogProvider } from "posthog-js/react"
if (typeof window !== "undefined") {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST
})
}
export function PHProvider({ children }: { children: React.ReactNode }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
}I don't get why, it's from official docs of vercel
https://vercel.com/guides/posthog-nextjs-vercel-feature-flags-analytics
1 Reply
Chinese softshell turtleOP
ok I had to change it to
.tsxAnswer