Hello, I am attempting to update the SDK to the la...
# ask-questions
Hello, I am attempting to update the SDK to the latest version to begin using sticky bucketing and payload encryption. However, I am encountering an error. The app in question is a NextJS app (page router). I am unsure of what I might be missing. Can you please help me with this issue? This is the code in my
Copy code
const growthbook = new GrowthBook({
  apiHost: "<https://cdn.growthbook.io>",
  clientKey: growthbookClientKey,
  enableDevMode: true,
  subscribeToChanges: true,
  decryptionKey: growthbookDecryptionKey,
  trackingCallback: (experiment, result) => {
    analytics.track(GA4_EXPERIMENT_VIEW, {
      experiment_id: experiment.key,
      variation_id: result.key,

function MyApp({ Component, pageProps }) {
//... Code omitted for brevity

    useEffect(() => {
    // Load features async
    let isMounted = true;
    if (isMounted && isReady && gaClientId) {
        id: gaClientId,
        url: window.location.href,

    if (isMounted && isReady) {
      growthbook.loadFeatures({ autoRefresh: true });

    return () => {
      isMounted = false;
  }, [isReady, gaClientId]);

//... Code omitted for brevity

export default MyApp;
I understand that for react native and nodejs SDKs I need to add the
polyfill, but this is not my case here, any ideas on what I am doing wrong? SDK version:
"<@U052WVA1MH6>/growthbook-react": "^0.24.0"
You may still need to apply the polyfill via
Copy code
  SubtleCrypto: require("node:crypto").webcrypto.subtle,
Depending on Node runtime, this may or may not be needed. Node 18+ should have
available on
, Node 17 only has
(no .subtle), and Node 16 has nothing.
Thanks @happy-autumn-40938. I’ll give it a try. I am using node 18+, though
Here’s an update on this if it’s useful for anyone. The
polyfill will not work on NextJS for client-side code, as
is unavailable in the browser environment; this will only work on server-side code or API routes. I ended up using this approach:
Copy code
import { Crypto } from '@peculiar/webcrypto';

const crypto = new Crypto();
  SubtleCrypto: crypto.subtle,