Skip to content

Use cookies instead of localStorage #2395

Answered by hasparus
AshMW2724 asked this question in Q&A
Discussion options

You must be logged in to vote

There's no supported way to do this, but it should be quite doable in userspace. Well, maybe a bit too much effort for a landing page, but if you're building a shared component library for your company, that seems fair enough.


So, Theme UI's ThemeProvider exported from theme-ui is made from ColorModeProvider, RootStyles and CoreProvider.

I'd create my own ColorModeProvider based on the one in Theme UI, but replace all localStorage related code with cookies.

Then you create your own top level provider like this ⬇️

import React from 'react'
import {
  jsx,
  useThemeUI,
  ThemeProvider as CoreProvider,
  

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AshMW2724
Comment options

Answer selected by AshMW2724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants