How Ssr code will work in Next js
If a page uses Server-side Rendering, the page HTML is generated on each request.
Server-side Rendering: The HTML is generated on each request. To make a page use Server-side Rendering, export getServerSideProps. Because Server-side Rendering results in slower performance than Static Generation, use this only if absolutely necessary.
const App = ({data}) => {
return (
<>
//jsx will go here // render the data
</>
)
}
export async function getServerSideProps() {
//fetching data from some api
const res = fetch('https://someapi.com/get')
const data = await res.json()
return {
props:{
data;
}
}
}
export default App;
Top comments (1)
i have made this boilerplate that aggregates all github boilerplates: github.com/maher-naija-pro/Best-Ne...