Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

so with Next for SSR you use React as a templating engine and just send that back?


Sort of. Next expects to find a file structure of scripts in the /pages directory. On the initial load of say www.nextsite.com/about/location, Next will by default try to render the file /pages/about/location.js or /location/index.js.

You can add an asynchronous function called .getInitialProps, which should return some props that are required for the page. On the initial load, Next will first run through getInitialProps, then render the actual component with those props. From then on, assuming you're using 'next/link' for routing, everything should work like a single page app. All of the pages except for the initial one are rendered on the client.


Kind of.... Just it is easier comparing with other server side web application framework...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: