Hi @wsaunders,
This issue is a known configuration challenge with Vercel. In certain Node server environments, the Builder SDK may require additional initialization steps, particularly for a package called isolated-vm
, which is used to safely evaluate your data bindings.
If you’re using Builder’s Gen 1 SDKs and data binding with a provider that uses edge workers (e.g., Cloudflare, Netlify, or Vercel), you might encounter issues where certain dependencies are automatically removed during ISR (Incremental Static Regeneration) functions.
Two key indicators can help identify this issue:
- Hydration errors: When SSR and client-side versions differ because the data binding did not execute on the server.
- Missing data: When data is missing on the server side but appears on the client side, indicating that data binding didn’t execute on the server.
This may result in a failure with the safeDynamicRequire
function. To resolve this, consider the following workaround.
For Next.js Pages Router:
In the pages/_document.jsx
file (or any server-only execution location), add the following code:
import ivm from 'isolated-vm';
import { Builder } from '@builder.io/react';
const isolate = new ivm.Isolate({ memoryLimit: 128 });
const context = isolate.createContextSync();
Builder.setServerContext(context);
If your project doesn’t have a _document.tsx
file, you can place the code elsewhere, but make sure to wrap it with this condition:
if (Builder.isServer) {
// Add the provided code here
}
For App Router:
In the page.tsx
responsible for rendering Builder content, import isolated-vm
at the start of the Page component:
export default async function Page(props) {
// Import must be inside the Page component
await import('isolated-vm');
//... the rest of your component logic
}
Then, in your next.config.js
, add isolated-vm
to the experimental.serverComponentsExternalPackages
list:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["isolated-vm"],
},
};
export default nextConfig;
For more details, please refer to the following link: Builder SDK Integration Tips.
I hope this helps! Let us know if you need further assistance or have any other questions.
Thanks,