Next.js Loading Speed Up
Unanswered
Chinese Alligator posted this in #help-forum
Chinese AlligatorOP
Hello everyone,
I’m currently working on a project using Next.js and ASP.NET Core, and I’m trying to improve the overall loading speed.
One of the challenges I’m facing is passing parameters without changing the route. For example, I want to keep the URL as /account instead of using something like /account?userid=*.
When the page loads, it needs to call several APIs — but those API calls depend on values stored in localStorage. So I can't use server Component.
I considered adding a caching layer, but since the data needs to stay up-to-date, caching doesn’t seem like the right fit.
I’m looking for the best way to handle this smoothly without affecting the route.
Thank you for your helping in advance.
I’m currently working on a project using Next.js and ASP.NET Core, and I’m trying to improve the overall loading speed.
One of the challenges I’m facing is passing parameters without changing the route. For example, I want to keep the URL as /account instead of using something like /account?userid=*.
When the page loads, it needs to call several APIs — but those API calls depend on values stored in localStorage. So I can't use server Component.
I considered adding a caching layer, but since the data needs to stay up-to-date, caching doesn’t seem like the right fit.
I’m looking for the best way to handle this smoothly without affecting the route.
Thank you for your helping in advance.
3 Replies
There are a few ways, cacheComponents 'use cache' in a child function after the auth in the parent, tanstck useQuery for client side caching, context to share the values( could be promfomaince issues with that tho) and I seen this new way with useSyncExternalStore
the trick with caching is to invalidate the data to keep it fresh
I'm a fan boy so I always say cache components is the way to go but its not for everyone