Watch keynotes and sessions from, our virtual developer conference.

ReferenceError: self is not defined

I’m using mongodb-stitch-browser-sdk 4.8.0.
I’m simply trying to import Stitch using this code…

import { Stitch } from ‘mongodb-stitch-browser-sdk’;

…and I get this error:

searchParams: ‘URLSearchParams’ in self,
ReferenceError: self is not defined

So this means the Stitch module won’t even load.
I’ve already tried using older versions of mongodb-stitch-browser-sdk.
Same error keeps coming up.

Are there any workarounds for this?

Hi @Jonathan_Gautier, welcome!

Are you importing this for the browser or are you executing this via node ? If you’re trying to build a server-side client application, try MongoDB Realm Node.js SDK instead.

If you’re still encountering this issue, could you provide steps and minimal reproducible example js ?