next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: React Context not persisting across client side page transitions. App router.

Open ehowey opened this issue 2 years ago • 3 comments

Summary

Hello!

I am running into an issue with React Context not persisting properly across page transitions when using the app router. It works in local dev, works on Vercel, but the context/state is resetting on each page transition with Netlify. Note this bug is only present when deployed, so tricky to debug and fix. The minimal reproduction is below.

Site on Netlify: https://nextjs-netlify-context-bug.netlify.app/ Site on Vercel: https://nextjs-netlify-context-bug.vercel.app/

A link to a reproduction repository

https://github.com/ehowey/context-bug

Expected Result

React context works properly and state is persisted across page transitions.

Actual Result

React context is resetting state on page transitions

Steps to reproduce

  1. Clone repo
  2. Deploy to Netlify

Next Runtime version

4.41.3

Is your issue related to the app directory?

  • [X] Yes, I am using the app directory

Build information

I used all of the default build settings and let Netlify autodetect NextJs.

ehowey avatar Dec 27 '23 16:12 ehowey

This looks like it's a result of this bug https://github.com/netlify/next-runtime/issues/2089 to me. I see a full page reload happening when navigating between pages on Netlify but not on Vercel.

Christopotamus avatar Jan 12 '24 23:01 Christopotamus

Yep that looks like it to me too. I'm surprised this isn't taking a bigger focus as it seems like a fairly major issue.

ehowey avatar Jan 13 '24 00:01 ehowey

We are experiencing the same thing, is there any chance of this being fixed any time soon?

mysterybear avatar Feb 02 '24 09:02 mysterybear

Duplicate of #2089

serhalp avatar Jun 04 '24 16:06 serhalp