Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Next.js App Dir with Builder V2 #3235

Open
RobSchilderr opened this issue Apr 24, 2024 · 2 comments
Open

Using Next.js App Dir with Builder V2 #3235

RobSchilderr opened this issue Apr 24, 2024 · 2 comments

Comments

@RobSchilderr
Copy link

RobSchilderr commented Apr 24, 2024

Describe the bug
In this example, provided by Builder.io, it is suggested to use the following code snippet:

  const { initializeNodeRuntime } = await import('@builder.io/sdk-react/node/init');
  initializeNodeRuntime();

However, initializeNodeRuntime does not seem to exist within the module, as evidenced by the following error screenshot:

Screenshot 2024-04-24 at 13 06 51

This issue occurs despite following the recommended setup. I would prefer to use this package due to its compatibility with the pages router in my project, which precludes using the Next.js SDK.

Additionally, I attempted to use the directive 'use client' at the top of the file to handle client-side custom components, but this approach failed to resolve the issue.

To Reproduce
Steps to reproduce the behavior:

  1. Initialize a new Next.js project (version 13.4.8) configured with the app router.
  2. Attempt to import initializeNodeRuntime as specified.
  3. Observe the error indicating that initializeNodeRuntime cannot be found.

Expected behavior

  • Being able to use App Router and Pages Router with Builder V2
  • Being able to register components, only client side components is okay.

Additional context

Using Next.js version 13.4.8 and following the guide provided in the Builder.io GitHub repository.

@khiemtong
Copy link

We ran into this (we're on NextJS 14.1) following the same instructions, the workaround is to manually declare the module (it is there in the package just not declared?)

Add something like decs.d.ts to your root

declare module '@builder.io/sdk-react/node/init';

@samijaber
Copy link
Contributor

Yes, there is an issue with the types not propagating correctly for certain TS configurations. We will investigate this, thanks for reporting.

The import itself should work correctly on the JS side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants