Skip to content

Feature request: custom storage (factory) #781

Open
@jamesarosen

Description

@jamesarosen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions