next.js
9be387c7 - getServerSideProps should support props value as Promise (#28607)

Commit
4 years ago
getServerSideProps should support props value as Promise (#28607) Previous to this change, getServerSideProps could only return plain objects for props, e.g.: ```javascript export async function getServerSideProps() { return { props: { text: 'some value', } } } ``` With this commit, the props object can also be a Promise, e.g. ```javascript export async function getServerSideProps() { return { props: (async function () { return { text: 'promise value', } })(), } } ``` For now, the framework simply waits for the results of the props Promise to resolve, but this small change sets the groundwork for later allowing props to be streamed (cc @devknoll). ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. -- *This is part of @devknoll's ongoing work to support streaming.* - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. *not sure if this applies here* - [ ] Errors have helpful link attached, see `contributing.md`
Author
Parents
Loading