#I thought Remix used SSR by default?

1 messages · Page 1 of 1 (latest)

pallid bone
#

Hey, I apologize if this is asked a lot or if I'm misunderstanding something. I come from Next.js, and in there, unless you specifically add "use client" at the top of your page, it runs on the server, meaning if you console.log, it'll show up in the terminal.

However that's not the case with Remix, as I'm currently testing, my logs are appearing on the browser. Is there a way to have SSR be on by default?

topaz fox
#

Remix always do SSR, but also hydrate your app client side

#

If you put a log in a component you should see it in both places

pallid bone
#

@topaz fox I just tried what you said, it logges on both server and client. Any time I refresh, it does that again, but any time I just ctrl + s, it only logs on the client. Is that a cashing thing?

Could you explain why it logs on both? That's a bit confusing for me.

Is it compiling everything on the server, which logs it on the server, then sending over the html/css to the client, and then the javascript to the client, which logs it on the browser?

topaz fox
#

When you save HMR refresh the component only on the browser

#

It logs on both because it runs on both

#

Remix doesn’t implement RSC, component have to run on the server to generate html and the browser to hydrate and update the DOM

pallid bone
#

Because we only send html to the client on first load, then hydrate, meaing the javascript will first run on the server

tiny python
#

Sounds right to me

topaz fox
#

That’s correct

#

Your components run server side to generate the html, the browser receives the html, load the JS, and hydrate the app