Next.js Discord

Discord Forum

why does next ship JS to the browser even when there isn't client-side code?

Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
haven't been using next since the app router was released and decided to check it yesterday. i created a simple server component that fetches a todo list from an api and use the data to render a list. i noticed that even though i don't have any interactivity on the client, JS is still shipped to the browser. is this expected? maybe i was naive, but i was thinking that this wouldn't be the case since this is a server component. here is the code:

5 Replies

I believe JS is still shipped to the browser for Next’s caching and other background shit to work. What you should be checking is to see if javascript was required to build the page’s HTML, if you run a curl on your local host and you get back HTML then you’re good Next is working like it’s supposed to.
If it was client side rendered you’d only see a div with an ID of “app” when you curl
If you truly want a no JS experience I’d use something other than Next
Northeast Congo LionOP
thanks for clarifying @archer !
it seems to be working as intended