Next.js Discord

Discord Forum

How to load pages faster

Unanswered
Yellowstripe scad posted this in #help-forum
Open in Discord
Yellowstripe scadOP
On my production and local environment, whenever I click switch details theres a few seconds where nothing happens, then it routes to the switch page. I'm not very sure why its so slow.

13 Replies

Yellowstripe scadOP
picture of home page
home page - gets the first 10 switches from the database and maps them out to switchCard
Switch card, takes the data and renders the switch card. the link at the bottom is what's slow
/switches/switch page, gets the switch from params and finds the switch in the db, passes it onto the client side component
the client side component, renders final picture see below *
final picture
Munchkin
The db is probably the bottleneck. I doubt it would make that much of a difference, but you could try switching off of prisma.
Also you’re not suspense-ing right. You have to wrap the component that’s making the async calls in a suspense for it to trigger. So that would make the page load faster with spinners.
thank you!!
this makes it sooo much better and faster
I didnt know thats how you're supposed to do it
Munchkin
Yup! I don’t love that it sort of dictates how you break up your components, but that’s how it works