Hi!
I’ve just started to play around with this package that makes it super easy to integrate SSR.
The thing is I do not know how to access the route/query params or such url data from within the server component, and therefore I can’t render a specific content. So for the code below, I don’t know how I could inject the documentId
into the Sample
server component. It is probably a specific react-router syntax injecting as a prop…?
This is mainly because I can’t use hooks in the server, hence no useParams
. But what’s the server alternative then?
Thanks!
function Sample(props) {
Meteor.subscribe('document', 'documentId');
const document = Documents.findOne();
return <h1>{document.title}</h1>
}
const AppRoutesSSR = [{
path: '/documents/:documentId'.
element: <Sample documentId='???documentId???' />
}, {
...
}]
renderWithSSR(AppRoutesSSR, {
renderTarget: 'root',
});