Michael Jones
Michael Jones

Reputation: 2272

Server side rendering with React, would the browser still need to load in React?

If I were to render all of my content for React on the server, would I still need to import React in the browser? I don't plan on using React-Router, and I know React is a bigger file, so it would be nice if I didn't have to load it each time.

Upvotes: 1

Views: 60

Answers (2)

Lukas Liesis
Lukas Liesis

Reputation: 26403

You can skip loading React in browser only when you don't need what react gives - extended interaction. Your HTML will work as always. If you have links (a tag) they will work, if you have html form (form tag) with standard submit buttons - it will work as well.

What will not work is all stuff written in react components, like you click on button/div/image... and some state changes.

All things which is not in basic HTML & basic HTML events, won't work.

No matter how you render html on server side if it's react, pure js, php, asp, .net, python or even C. Browser gets HTML and displays it, binds default events, applies default browser styling, then override stuff with your css/js code.

Upvotes: 1

Crysfel
Crysfel

Reputation: 8158

You do need it if you are planning to allow the user to interact with the components or your app, if you are just rendering text without any button or any other interaction, then I guess it would not be required.

Upvotes: 1

Related Questions