Hey Folks- im trying to use KV/D1 inside a Server component, is this possible or only inside an API

Hey Folks- im trying to use KV/D1 inside a Server component, is this possible or only inside an API route? I can't find any examples online

I've got this in my next.config.js, but process.env.TESTKV is always undefined

if (process.env.NODE_ENV === 'development') {
  import('@cloudflare/next-on-pages/next-dev').then(({ setupDevBindings }) => {
      setupDevBindings({
        bindings: {
          // Add here the Cloudflare Bindings you want to have available during local development,
          // for more details on Bindings see: https://developers.cloudflare.com/pages/functions/bindings/)
          //
          // KV Example:
          TESTKV: {
            type: "kv",
            id: "TESTKV",
          },
        },
      });
  })
}
Was this page helpful?