G
G
gomerIT2021-03-19 22:23:23
JavaScript
gomerIT, 2021-03-19 22:23:23

Does NextJS dynamic page rendering work only through special functions?

So far I have not found the answer to my question in the documentation itself. I am using express to manage my routing. Let's say I want to display information about the user on the page, and immediately pass the data to the component, but I don't know how to do it. Now the component render looks something like this:

router.get('/profile/user', (req, res) => {
  app.render('/user'); // Путь к компоненту
});

The documentation describes 2 functions for getting data from the server getstaticprops(), getserversideprops() and both examples used fetch to get the data. Isn't it possible, as in PHP, to immediately transfer data to the layout without making additional requests to the server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2021-03-19
@gomerIT

https://nextjs.org/docs/basic-features/data-fetch...
On the server, push the data into req, you can get it from the context in the next.
You are also rendering incorrectly.
https://nextjs.org/docs/advanced-features/custom-server
https://github.com/vercel/next.js/tree/canary/exam...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question