I need to render my React app from the server side. For that, i am using the framework next.js. But i am facing two issue.
First, i need to serve my app dynamically. That means i need a server side router to display my react components according to the current url.
Then, i need to load some dynamic data before render my components. So i need to pass these data from node to my react component.
this is my current situation :
// In Node.js
app.get("/",function(req,res){
return app.prepare()
.then(() => handle(req, res))
.catch(ex => {
console.error(ex.stack)
process.exit(1)
})
})
//In React.js
import React from 'react'
export default class Index extends React.Component{
render(){
return(
<div>
<p>Hello Server Side Rendered React App from Google Cloud Front</p>
</div>
)
}
}
So , What should i do ?