Skip to content

Commit 5642796

Browse files
authored
docs: update readme
Updated the README.md to use the nextjs internal `getServerSideProps` function in favor of the deprecated `getInitialProps`
1 parent c86de2b commit 5642796

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Try a demo of the example code below here:
2626

2727
### [Demo on CodeSandbox](https://codesandbox.io/s/charming-herschel-7z362)
2828

29-
## `getInitialProps` cookies (SSR + Client)
29+
## `getServerSideProps` cookies (SSR + Client)
3030

3131
```js
3232
import { parseCookies, setCookie, destroyCookie } from 'nookies'
@@ -47,12 +47,12 @@ export default function Me({ cookies }) {
4747
)
4848
}
4949

50-
Me.getInitialProps = async function({ ctx }) {
50+
export async function getServerSideProps({ ctx }) {
5151
// Parse
5252
parseCookies(ctx)
5353

5454
// Set
55-
setCookie(ctx, 'fromGetInitialProps', 'value', {
55+
setCookie(ctx, 'fromGetServerSideProps', 'value', {
5656
maxAge: 30 * 24 * 60 * 60,
5757
path: '/',
5858
})
@@ -73,7 +73,7 @@ export default function Me () {
7373
return <div>My profile</div>
7474
}
7575

76-
Me.getInitialProps = async function({ ctx }) {
76+
export async function getServerSideProps({ ctx }) {
7777
// Parse
7878
nookies.get(ctx)
7979

0 commit comments

Comments
 (0)