Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Description
I'm trying to follow this guideline https://github.com/optimizely/react-sdk?tab=readme-ov-file#server-side-rendering and setting up a Optimizely Server Provider that can run in Nextjs server
In OptimizelyServerWrapper.tsx
export const OptimizelyServerWrapper = async ({
children
}: OptimizelyServerWrapperProps) => {
const resp = await fetch(
`https://cdn.optimizely.com/datafiles/<your_key>.json`
)
const datafile = await resp.json()
const optimizelyClient = createInstance({
datafile
})
return (
<OptimizelyProvider
optimizely={optimizelyClient}
user={{ id: uuidv4() }}
isServerSide={true}
>
{children}
</OptimizelyProvider>
)
}
In layout.tsx
<OptimizelyServerWrapper><MyComponent /></OptimizelyServerWrapper>
When running, it throw error
Server Error
Error: (0 , {imported module [project]/nodemodules/next/dist/server/future/route-modules/app-page/vendored/rsc/react.js [app-rsc] (ecmascript)}.createContext) is not a function
As checking, seems like we can NOT import createInstance
in server component. I'm using Nextjs version 14. I'm NOT sure if anyone face this issue.
React Framework
Nextjs 14