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

Feature request: custom storage (factory) #781

Open
jamesarosen opened this issue Dec 22, 2023 · 3 comments
Open

Feature request: custom storage (factory) #781

jamesarosen opened this issue Dec 22, 2023 · 3 comments

Comments

@jamesarosen
Copy link

jamesarosen commented Dec 22, 2023

I'd like to use Vercel KV as my storage. It's an implementation of Redis, but it doesn't expose a Redis URL. Instead, there's a JavaScript client library that supports the same methods.

Ideally, there would be some contract, expressed as a TypeScript interface, for a custom storage. I'd then be able to pass in my own factory instead of "memory" or "redis".

const factory = SplitFactory({
  storage: () => new MyCustomVercelKVStorage(),
})

Currently, that's impossible because getStorage is closure-scoped, as is getModules, which calls it.

Some additional benefits of this approach:

  • people could use other storage mechanisms like localStorage or Cloudflare KV
  • bundlers would be able to tree-shake this library better. As-is, they have to include both the memory and redis storage options because they're both required statically and resolved by a ternary statement
@jamesarosen
Copy link
Author

Ah! This example suggests the solution is to use PluggableStorage from the browser SDK.

@jamesarosen
Copy link
Author

This issue seems relevant again now that this library's README says,

The JavaScript SDK is an isomorphic library for both Node.js and Web browser environments.

@EmilianoSanchez
Copy link
Contributor

Yes @jamesarosen ,

As explained here, this package doesn't support custom storages yet :/.

Because of the benefits you mentioned, we plan to support it, but there is no ETA yet.
Let's keep this issue open until we have a solution for it.

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

No branches or pull requests

2 participants