Skip to content

Commit

Permalink
fix: docs, add variable cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
wootsbot committed Jun 19, 2020
1 parent 79be2bc commit f1aa4b2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -49,7 +49,7 @@ export default function Me({ cookies }) {

export async function getServerSideProps({ ctx }) {
// Parse
parseCookies(ctx)
const cookies = parseCookies(ctx)

// Set
setCookie(ctx, 'fromGetServerSideProps', 'value', {
Expand All @@ -60,22 +60,22 @@ export async function getServerSideProps({ ctx }) {
// Destroy
// destroyCookie(ctx, 'cookieName')

return { cookies };
};
return { cookies }
}
```

OR

```js
import nookies from 'nookies'

export default function Me () {
export default function Me() {
return <div>My profile</div>
}

export async function getServerSideProps({ ctx }) {
// Parse
nookies.get(ctx)
const cookies = nookies.get(ctx)

// Set
nookies.set(ctx, 'fromGetInitialProps', 'value', {
Expand All @@ -86,7 +86,7 @@ export async function getServerSideProps({ ctx }) {
// Destroy
// nookies.destroy(ctx, 'cookieName')

return { cookies };
return { cookies }
}
```

Expand All @@ -111,7 +111,7 @@ function handleClick() {
// destroyCookie(null, 'cookieName')
}

export default function Me () {
export default function Me() {
return <button onClick={handleClick}>Set Cookie</button>
}
```
Expand Down

0 comments on commit f1aa4b2

Please sign in to comment.