Documentation needs to mention writing server-side code in GS(S)P props earlier
See original GitHub issueLots of users miss that they can write server side code in getStaticProps
and getServerSideProps
.
We also see numerous issues about people trying to fetch API routes. We need to fix this in the documentation by making this one of the first things we have in the docs.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Server Side Render Dynamic Page based on Route Param
I don't want to call api and get the data using useEffect inside the component. File: pages/post/[code].js import React from 'react'; import ...
Read more >Data Fetching: getServerSideProps - Next.js
Pages using getServerSideProps will be server side rendered at request time and only be cached if cache-control headers are configured. If you do...
Read more >Using Queries - Blitz.js
In a React Component. To use one of your Blitz queries, call the useQuery hook with: Your query resolver; The input arguments for...
Read more >Known Incompatibilities with Previous Releases ... - Documentation
In MarkLogic 10, when you write documents with the REST API using PUT v1/documents, the documents have the union of the following permissions:....
Read more >Fetch props directly from the Database?!?! New Hooks in Next ...
Next.js 9.3 came out with 3 new hooks that allow you to fetch data in different ways: - getServerSideProps: Fetch data server side...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Throwing my opinion down here - I don’t think this is fixed. I found this issue via blame’ing the note in the docs because it confused me even further. Why can we not fetch API routes? This has broken my mental model of how Next.js used to work (i.e. fetch from API during SSR).
Two notes on the content of the fix:
How do we call the function itself? How do we access the data? Do you mean repeat the data fetching (i.e. DB calls) in the API route in the
getServerSideProps
method? I think I’m misunderstanding something here.Without any indication how to approach this refactor or what the refactor entails makes for a pretty frustrating read. I think pointing to an example here of an app using API routes in SSR would be really useful. I’m currently lost and regretting my decision to use API routes because of the complexity and hidden constraints.
I will take this up.