Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to use sessionStorage instead of localStorage #71

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

macguirerintoul
Copy link

No description provided.

@pacocoursey
Copy link
Owner

Thanks! I'd like to think about how to support this better than just a boolean. I wonder if we're missing any other common storage providers that would warrant this being a generic cache option. Or perhaps caching/syncing can be turned off entirely.

@pacocoursey pacocoursey marked this pull request as draft May 15, 2022 20:19
@pacocoursey pacocoursey added the v1 Planned for v1 label May 15, 2022
@jasongerbes
Copy link

@pacocoursey, you could alternatively add a storage?: 'local' | 'session' | Storage; prop to ThemeProvider to allow for local/session/custom storage implementations:

// localStorage (default)
function MyApp({ Component, pageProps }) {
  return (
    <ThemeProvider storage="local">
      <Component {...pageProps} />
    </ThemeProvider>
  )
}
// sessionStorage
function MyApp({ Component, pageProps }) {
  return (
    <ThemeProvider storage="session">
      <Component {...pageProps} />
    </ThemeProvider>
  )
}
// Custom storage implementation
const myCustomStorage: Storage = { /* Implementation here */ };

function MyApp({ Component, pageProps }) {
  return (
    <ThemeProvider storage={myCustomStorage}>
      <Component {...pageProps} />
    </ThemeProvider>
  )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
paused v1 Planned for v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants