builder icon indicating copy to clipboard operation
builder copied to clipboard

Blank page with next js app router

Open PhilGarb opened this issue 1 year ago • 6 comments

Describe the bug Published pages are blank when using next js app router. They show up fine in the preview.

To Reproduce Steps to reproduce the behavior:

  1. Please see the following codesandbox
  2. Edit the url to include: /home at the end.
  3. See that the page is blank without any errors.

Expected behavior I expect the page not to be blank or tell me what I have misconfigured.

Additional context I understand that the main examples of integrating next js are using the pages directory. I do however not see why this should not work. It does work fine for the preview.

PhilGarb avatar Apr 20 '23 12:04 PhilGarb

I've also tried setting up under app/builder/[[...page]]/page.tsx but am getting the error below (screenshot)

I've followed all the steps provided in the official docs (Next App Router)

Screen Shot 2023-05-26 at 5 51 55 PM

mitchuman avatar May 27 '23 00:05 mitchuman

I found that if you add query param '?builder.preview=page' in the URL it show up.

JABvzla avatar Jul 10 '23 12:07 JABvzla

any insight on this? I've noticed the same as well. I get a 404 unless i place ?builder.preview=page at the end of the url

FutureFutureTo avatar Jul 10 '23 16:07 FutureFutureTo

Hey folks, we have updated our docs on using the App router. Take a look here: https://www.builder.io/c/docs/integrating-builder-pages#add-a-builder-component-to-your-app

These new docs should get your app working properly without the need for a query param change.

samijaber avatar Jul 31 '23 18:07 samijaber

So I've checked the sandbox, and to get it working, all that's need to be done is update theses packages to their latest versions:

“@builder.io/react”: “^3.0.8",
“@builder.io/sdk”: “^2.0.5",
“next”: “^13.4.12",

Here's a link to a working SandBox: https://codesandbox.io/p/sandbox/strange-snow-84njm7

hamatoyogi avatar Aug 01 '23 04:08 hamatoyogi

I am using @builder.io/react on version 3.1.1 with React 17 and followed the documentations posted above. Unfortunately the issue persists.

After some digging and trial-n-error, I have found a workaround that worked for me:

Instead of

<BuilderComponent model="page" content={content} />

I used:

<BuilderComponent model="page" data={content?.data} />

HypernovaTX avatar Feb 01 '24 21:02 HypernovaTX

Closing as I believe this is fixed now. We have also updated all of our docs around the App Router, and they should all be in working order.

samijaber avatar Apr 09 '24 16:04 samijaber