Replies: 2 comments
-
Waiting for the client to resolve the API request before rendering would be done with React (Next.js doesn't expose anything special for this). You can do something similar to: function Page() {
const [data, setData] = useState()
useEffect(() => {
async function fetchData() {
// data fetching logic
// once data is retrieved, call setData() w/ data to update state
}
fetchData()
})
if (!data) return <div>Loading ...</div>
return <div>Cool page with {data}</div>
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, it does call API every time irrespective of whether rendering is happening on the server-side (first request) or client-side (subsequent requests). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As simple as the example in the docs...

Does this API get called every time the client enters the page on client-side?
If no, Is there something similar in Next.js so that in my use case I want to wait for client-side API call before rendering the page?
Beta Was this translation helpful? Give feedback.
All reactions