Skip to content

Instantly share code, notes, and snippets.

View manoj-mukherjee-maersk's full-sized avatar

Manoj Mukherjee manoj-mukherjee-maersk

View GitHub Profile
@spro
spro / next-ssr-recoil.js
Last active January 7, 2024 16:22
Attempt at SSR with Recoil - setting initial atom values with Next.js getServerSideProps
import {useEffect} from 'react'
import {RecoilRoot, useRecoilState, atom} from 'recoil'
// User data
const user1 = {username: 'joe', bio: "You will never see me, unless of course this example is totally broken."}
const user2 = {username: 'bob', bio: "I am the one true user."}
const user3 = {username: 'fred', bio: "Just kidding, make way for the new guy."}
// Recoil atom to store user. The default user is user1, but it will be