supabase-js: Property 'structuredClone' doesn't exist

Describe the bug

When attempting Apple sign‑in in an Expo app using @supabase/supabase-js@2.51.0, the client throws a runtime ReferenceError: Property 'structuredClone' doesn't exist. This error occurs regardless of JS engine (Hermes or JSC) and blocks native authentication flows that rely on structuredClone.

To Reproduce

  1. In a fresh Expo SDK 53 project, install Supabase JS at v2.51.0:

    npm install @supabase/supabase-js@2.51.0
    
  2. Configure jsEngine to either Hermes or JSC in app.json.

  3. Use this minimal repro code:

    import * as AppleAuthentication from 'expo-apple-authentication';
    import { supabase } from './supabaseClient';
    
    export async function signInWithApple() {
      try {
        const credential = await AppleAuthentication.signInAsync({
          requestedScopes: [
            AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
            AppleAuthentication.AppleAuthenticationScope.EMAIL,
          ],
        });
    
        if (!credential.identityToken) {
          throw new Error('No identityToken returned from Apple.');
        }
    
        const { error, data: { user } } = await supabase.auth.signInWithIdToken({
          provider: 'apple',
          token: credential.identityToken,
        });
    
        if (error) {
          console.error('Supabase auth error:', error);
        } else {
          console.log('✓ Signed in:', user);
        }
      } catch (e: any) {
        if (e.code === 'ERR_REQUEST_CANCELED') {
          console.log('User cancelled Apple sign‑in');
        } else {
          console.error(e);
        }
      }
    }
    
  4. Run the app and attempt Apple sign‑in.

  5. Observe the Metro console error:

    ReferenceError: Property 'structuredClone' doesn't exist
    

    The app crashes before completing the flow.

Expected behavior

Native sign‑in flows should work without requiring a global structuredClone. The client should either polyfill it on unsupported engines or avoid relying on it entirely. Behavior should match v2.50.5, where Apple sign‑in works under Expo.

Screenshots

n/a — error is shown in Metro/console and app terminates.

System information

  • Expo SDK: 53 (React Native 0.79.5)
  • JS Engine: Hermes (also reproduces on JSC)
  • Version of @supabase/supabase-js: 2.51.0
  • Version of Node.js: 18.16.0
  • Library for Apple auth: expo-apple-authentication@7.2.4

Additional context

  • Downgrading to @supabase/supabase-js@2.50.5 resolves the issue: Apple sign‑in completes successfully under Expo when using v2.50.5.
  • A fix has been proposed in Expo’s PR [#37503](https://github.com/expo/expo/pull/37503), which would add a structuredClone polyfill for native apps. That PR is still open, all CI checks are passing, but it’s awaiting at least one approving review and resolution of a few reviewer concerns (stringification logic and transfer semantics) before merge.
  • Once merged—or if Supabase JS bundles its own fallback—the Apple sign‑in error should be resolved. Let me know if you need further logs, test results under Hermes, or any adjustments to the proposed implementation.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 22
  • Comments: 19 (3 by maintainers)

Commits related to this issue

Most upvoted comments

“@supabase/supabase-js”: “2.50.0”, use this version

Hey all, We’ve fixed the issue in the latest version of the supabase-js library.

You can use "@supabase/supabase-js": "2.52.0"

edit: Thanks @devasidmi for the very detailed report!

“@supabase/supabase-js”: “2.50.0”, use this version

it didnt work for me

It seems to be working now with version 2.52.0! Thank you @cemalkilic ❤️

Manage to solve it by polyfill structured-clone with https://github.com/ungap/structured-clone in App.tsx

import structuredClone from "@ungap/structured-clone";
if (!("structuredClone" in global)) {
  global.structuredClone = structuredClone;
}

Expo SDK: 53(React Native 0.79.5) @supabase/supabase-js: 2.51.0 Node.js : 22.17.1

I’m encountering the error Property ‘structuredClone’ doesn’t exist even when attempting to log in with Kakao or Google.

Downgrading the supabase-js version was not a viable solution for me.

Due to this issue, I’m having difficulty making progress on my project. Is there any workaround or temporary solution available that I could use in the meantime?

Just adding this snippet to _layout.tsx or index.tsx works as a quick fix. Fingers crossed the PR gets merged soon.

if (typeof global.structuredClone === "undefined") { global.structuredClone = (value) => JSON.parse(JSON.stringify(value)); }

@bakerfugu the package itself is supposed to resolve the issue 🤦 what line of code did you add that file in your index.js please.

Even with #1507 still same problem happen.

Did you try with supabase-js version 2.52.0 ?