We noticed our website displays a white page on older versions of Safari (IOS et MacOS).
Apparently, this is related to globalThis that is not supported on Safari 12.1 or before.
On a page using prismic.createClient(endpoint);, we have this :
ReferenceError: Can't find variable: globalThis
We use this stack:
"next": "^12.1.5",
"@prismicio/client": "^6.0.0",
And when we follow the trace, we notice globalThis is used in the definition of class Client directly in the lib "@prismicio/client"; when we call prismic.createClient(endpoint);
We create and use our prismic client on server side.
We already tried to define globalThis if it's undefined or use a polyfill, but I guess the error happens before that, during the definition of the class Client.
Have you a solution or a tip to fix this kind of issues?
We used globalthis package and call the method shim() just before initialization of the Prismic Client (in a custom prismic helpers file).
We use this client on server and client side, so we needed to declare globalThis not only in _app.tsx or in our getServerSideProps in route templates.
// ~/utils/prismicHelpers.ts
import globalthis from "globalthis";
import * as prismic from "@prismicio/client";
import { endpoint } from "../prismicConfiguration";
/**
* globalThis polyfill:
* Prevent error on IOS/MacOS version 12.1 or before
* ReferenceError: Can't find variable: globalThis
*/
globalthis.shim();
/**
* PRISMIC CLIENT
*/
// Initialises the Prismic Client that's used for querying the API and passes it any query options.
const prismicClient = prismic.createClient(endpoint);