Skip to content

Instantly share code, notes, and snippets.

@yoovanr
Created June 30, 2021 11:56
Show Gist options
  • Save yoovanr/3af70ced149e629e66004d7324e3bd65 to your computer and use it in GitHub Desktop.
Save yoovanr/3af70ced149e629e66004d7324e3bd65 to your computer and use it in GitHub Desktop.
// pages/_app.js
import React from 'react'
import CookiesUtils from '../utils/cookies'
const App = () => {
// ...
}
App.getInitialProps = async ({ ctx }) => {
// ...
CookiesUtils.setServerSideCookies(ctx)
CookiesUtils.setItem('server-side-cookies', 'Aloha from server side cookies!')
CookiesUtils.getItem('server-side-cookies') // Output: Aloha from server side cookies!
// ...
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment