Skip to content

Instantly share code, notes, and snippets.

@martiuh
Last active March 21, 2020 02:19
Show Gist options
  • Save martiuh/c94a0f791a82339ba96b0f22dec2ca4c to your computer and use it in GitHub Desktop.
Save martiuh/c94a0f791a82339ba96b0f22dec2ca4c to your computer and use it in GitHub Desktop.
Brief SSR Explanation

Imaginemos que la página es esto

function App() {
    <h1>Hello World</h1>
}

con client side tu mandas un index.html vacío como este

<html>
   <div id="root">
    </div>
</html>

Luego en tu JS tienes algo como esto

ReactDOM.render(<App />, document.getElementById("root"))

Con SSR corres react en el servidor y mandas el resultado al cliente, entonces tu index.html se ve así

<html>
   <div id="root">
     <h1>Hello World</h1>
   </div>
</html>

Y tu JS se ve así

ReactDOM.hydrate(<App />, document.getElementById("root"))

Esto significa que el cliente hace menos chamba de incio para iniciar react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment