To use Next.js for server-side rendering (SSR) in JavaScript, follow these steps:
17 chars2 lines
or
14 chars2 lines
Create a pages directory in your project root directory.
Create a JavaScript file in the pages directory with the name of the route you want to create. For example, if you want to create a route for /about, create a file called about.js in the pages directory.
In the JavaScript file, export a function called getServerSideProps
which returns an object with the data to be used when rendering the component. This function will be called at runtime on the server-side before rendering the component.
index.tsx262 chars9 lines
getServerSideProps
function as props.index.tsx130 chars11 lines
dev
command:12 chars2 lines
or
9 chars2 lines
gistlibby LogSnag