I have a Next.js 13 app that was deployed to the Edge on Cloudflare Pages with experimental: { runtime: 'experimental-edge' }
, but requirements were updated and I need to include our feature flag dependency LaunchDarkly - and retrieve the feature flags via getServerSideProps
.
Inside getServerSideProps
I tried launchdarkly-node-server-sdk
, launchdarkly-node-client-sdk
, and launchdarkly-js-client-sdk
, but they either require a Node specific library (fs
and others) or window
.
launchdarkly-cloudflare-edge-sdk
with @cloudflare/kv-asset-handler
looks promising, so I followed the template, but I'm not sure how to extend a Next.js app to have this functionality. For example, do I put the worker into a middleware.ts
function or somehow extend the vercel build
step to include this functionality.