Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent to getServerSideProps and getStaticProps in Next.js 14? [duplicate]

I'm trying to understand how SSR/SSG/ISR rendering behavior works in Next.js version 14 with the new app router. In the past I remember that Next.js offered reserved functions called getServerSideProps to fetch or do some work in the server (SSR) or the getStaticProps to generate the data during the build and cache it on the server (If I understand correctly).

What is the equivalent for these in Next.js 14 with the new app router? Also, I saw in the docs that they are showing only examples with the fetch native API, Can I use axios library to make HTTP request and have the same behavior?

Thanks!

like image 582
Netanel Vaknin Avatar asked Nov 01 '25 17:11

Netanel Vaknin


1 Answers

You can use any kind of method for fetching data in pages files. You should use promises direct in the page Component. Here is the documentation where you can see how to do that.

like image 147
Alexander Tigselema Avatar answered Nov 03 '25 07:11

Alexander Tigselema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!