DEV Community


How to get data from API and show static data from server using NextJS?

sunflower profile image sunflowerseed ãƒŧ1 min read

It'd be simple to write a React app in 3 minutes to get the weather data from,80/forecast and show it on the page, except we cannot show the data if it is a search engine looking into our page.


In other words, if we curl our page, we won't be able to see the weather info. Anybody know how to do it in 5 minutes using NextJS? Any other alternatives other than NextJS? Many thanks.

Discussion (3)

Editor guide
mkubdev profile image
Kubdev • Edited

Hey, you need to create an API Endpoint who send the request from weatherAPI

sunflower profile image
sunflowerseed Author • Edited

Ok, I found later: check out getServerSideProps() to do SSR, and getStaticProps() to do Static Generation... just read the docs on how to use them.

Here is a demo:

mkubdev profile image

You should do the tutorial of next.js, it's cover all concepts