question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: SSR mode has stopped working in built Next.js app

See original GitHub issue

Provide environment information

  System:
    OS: Windows 10 10.0.22000
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 4.89 GB / 15.93 GB
  Binaries:
    Node: 19.2.0 - ~\scoop\apps\nodejs\current\node.EXE
    npm: 8.19.3 - ~\scoop\apps\nodejs\current\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (107.0.1418.62)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @tanstack/react-query: ^4.19.0 => 4.19.0
    @trpc/client: ^10.4.3 => 10.4.3
    @trpc/next: ^10.4.3 => 10.4.3
    @trpc/react-query: ^10.4.3 => 10.4.3
    @trpc/server: ^10.4.3 => 10.4.3
    next: 13.0.6 => 13.0.6
    react: 18.2.0 => 18.2.0
    typescript: ^4.9.3 => 4.9.3

Describe the bug

With ssr: true, Next.js and React Query renders the tRPC query with SSR prepass as expected in dev mode.

However, after building the app using npm run build and then npm run start, it doesn’t render the page with an SSR prepass. The initial load still shows the “Loading…” message / has no data.

refetchOnWindowFocus works still, so the issue is with the initial SSR prepass on a built Next.js app.

Link to reproduction

https://github.com/austins/trpc-nextjs-ssr_not_working_in_build-repro

To reproduce

  1. Have ssr: true
  2. Build Next.js app
  3. Run built Next.js app
  4. See that it doesn’t load the initial data via SSR prepass

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I’d be down to file a PR fixing this bug!

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
KATTcommented, Dec 3, 2022

My guess would be something changed within Next

0reactions
austinscommented, Dec 5, 2022

Closing as this isn’t a tRPC issue, but an issue with Node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

After updating to nextjs 12.0.1, next-middleware-ssr-loader ...
After updating to nextjs 12.0.1, next-middleware-ssr-loader gives an error saying _document not found. #30501.
Read more >
react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >
Advanced Features: Debugging - Next.js
Using the Debugger in Jetbrains WebStorm​​ Run this debug configuration, and the selected browser should automatically open. At this point, you should have...
Read more >
Advanced Features: Custom Server - Next.js
Start a Next.js app programmatically using a custom server. ... If you have an existing backend, you can still use it with Next.js...
Read more >
Advanced Features: Error Handling - Next.js
js application, you will encounter an overlay. It is a modal that covers the webpage. It is only visible when the development server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found