#Using Client component in layout.js

62 messages · Page 1 of 1 (latest)

grim scarab
#

I want to use the layout as a client component and have useEffect to fetch data.. its because server components are slow when switching routes

opaque obsidianBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

grim scarab
#

because the layout loads data, and the redirecting takes like 3 mins

#

i want it to go to a different route instantly

trail creek
grim scarab
#

it doesnt feel smooth

trail creek
#

It won't make much difference. just rendering will take time

grim scarab
#

but like how are other websites extremely fast in switching routes

trail creek
grim scarab
#

like the vercel website itself

#

it loads everything instantly

grim scarab
trail creek
#

Ya, I'll also hate you

grim scarab
#

so what do i do to increase speed

trail creek
grim scarab
#

as in it shows those loading components

#

it doesnt buffer the whole page

trail creek
#

Can you give a minimum repro repo on where you face speed issues? Because I don't face any

grim scarab
#

i clicked sell

#

and it took like 5 secs

#

to redirect

#

on production

#

i feel like its because of server components

trail creek
#

Are you using the Link element for urls?

grim scarab
#

no <a> tags

#

cause Link is even slower

trail creek
trail creek
grim scarab
#

but like <Link> is even slower than a tags

trail creek
grim scarab
#

yea

#

i initially had that

#

Link doesnt even show any sort of loading

#

<a> atleast shows that the website buffers

#

its also slower

#

idk

#

whats the cause

trail creek
#

I'll need a min reproduction repo

#

because its a unexpected behaviour

#

and whats your nextjs version

grim scarab
#

would making the route itself client

#

but have server component inside

#

work

grim scarab
trail creek
#

Just create a minimum reproduction repo & send it here

grim scarab
#

idk how to do that lol

trail creek
#

you can google it!

grim scarab
#

can u give me some advice

#

is it fine if i fetch data in layout

#

and pass it

#

but idk how to pass it to children

trail creek
#

no

grim scarab
#

💀

#

sorry

trail creek
#

you should delete above messages ASAP

grim scarab
#

why what happened

#

i just asked for help

#

i didnt ask for planting bomb

trail creek
#

ignore it then, if you don't want to.