i think im doing something wrong with my initial s...
# ask-questions
b
i think im doing something wrong with my initial setup here. we have a nextjs app, i want to be able to use growthbook sdk in both the frontend code as well as the backend code. >>>
the setup instructions for use in nextjs (using @flags-sdk/growthbook) have a comment: "Define a server-side tracking callback. Note: Client-side tracking is also available but requires additional setup." but it doesnt say exactly what the additional setup is. so i skipped the nextjs sdk setup and started with a reactjs sdk connection and tried implementing that. but even though it sort of looks like its working, im still getting server log errors yelling that "Error: autoAttributesPlugin only works in the browser" even though all the nextjs code where i reference growthbook has 'use client' at the top
is there a canonical example somewhere using growthbook in a next js app both server side and client side?
h
Vercel's Flags SDK and the GB provider built for it are, by design, backend-only. Our Flags SDK adapter always evaluates flags and experiments on the backend and can either fire tracking on the back-end or SSR inject a bit of front-end tracking code for the browser to fire as deferred tracking calls. You can see how this is configured in our docs (which reference this example Next.js app) If you want to evaluate flags and experiments on the front-end, then the React SDK is generally the best way to achieve this. If you've created a clear boundary between client and server components and only invokes the React SDK on the client side, then you should never see "Error: autoAttributesPlugin only works in the browser" in your server logs. In fact, you should never see server logs at all for the client side SDK. Is it possible you're using the SDK in a hybrid context somehow?