{"id":13687284,"url":"https://github.com/skymethod/kv-connect-kit","last_synced_at":"2026-02-25T20:31:05.402Z","repository":{"id":195866880,"uuid":"692806941","full_name":"skymethod/kv-connect-kit","owner":"skymethod","description":"Minimal Typescript client implementing the KV Connect protocol. Access Deno KV remotely from any Javascript environment like Node, Cloudflare Workers, Bun, Deno, and the browser.","archived":false,"fork":false,"pushed_at":"2024-01-12T23:42:52.000Z","size":1463,"stargazers_count":58,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-18T23:03:08.210Z","etag":null,"topics":["deno","kv"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skymethod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://buy.stripe.com/6oE7v22Q74nvakwaEE"]}},"created_at":"2023-09-17T16:34:26.000Z","updated_at":"2025-08-25T17:14:58.000Z","dependencies_parsed_at":"2023-09-19T23:43:03.572Z","dependency_job_id":"94acfbff-2ce4-4f9a-8d9a-fdc3b7f839e4","html_url":"https://github.com/skymethod/kv-connect-kit","commit_stats":{"total_commits":216,"total_committers":2,"mean_commits":108.0,"dds":0.03240740740740744,"last_synced_commit":"0e44f7d494089e11ae723341e96e799a46173445"},"previous_names":["skymethod/kv-connect-kit"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/skymethod/kv-connect-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skymethod%2Fkv-connect-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skymethod%2Fkv-connect-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skymethod%2Fkv-connect-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skymethod%2Fkv-connect-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skymethod","download_url":"https://codeload.github.com/skymethod/kv-connect-kit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skymethod%2Fkv-connect-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29838032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T19:08:47.527Z","status":"ssl_error","status_checked_at":"2026-02-25T18:59:04.705Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","kv"],"created_at":"2024-08-02T15:00:51.575Z","updated_at":"2026-02-25T20:31:05.376Z","avatar_url":"https://github.com/skymethod.png","language":"TypeScript","funding_links":["https://buy.stripe.com/6oE7v22Q74nvakwaEE"],"categories":["KV Connect protocol","TypeScript"],"sub_categories":[],"readme":"# kv-connect-kit\n\nMinimal Typescript client implementing the [KV Connect protocol](https://github.com/denoland/deno/tree/main/ext/kv#kv-connect). Access [Deno KV](https://deno.com/kv) remotely from any Javascript environment like Node, Cloudflare Workers, Bun, Deno, or the browser. \n\n- Use `makeRemoteService` to provide your access token and configure optional setup params\n- Use the returned service to call `openKv` (equiv to [`Deno.openKv`](https://deno.land/api?s=Deno.openKv\u0026unstable))\n- The `KV` instance returned can be interacted with via the standard [KV api](https://deno.land/api?s=Deno.Kv\u0026unstable) in any Javascript environment.\n\n### Quick start - Deno\n\n```ts\nimport { makeRemoteService } from 'https://raw.githubusercontent.com/skymethod/kv-connect-kit/v0.0.5/src/remote.ts';\n\nconst accessToken = Deno.env.get('DENO_KV_ACCESS_TOKEN');\nif (accessToken === undefined) throw new Error(`Set your personal access token: https://dash.deno.com/account#access-tokens`);\n\n// make a local openKv function, optionally wrap unsupported serialized byte values as UnknownV8\nconst { openKv } = makeRemoteService({ accessToken, wrapUnknownValues: true });\n\n// open the database connection, use the url from project dashboard: https://dash.deno.com/projects/YOUR_PROJECT/kv\nconst kv = await openKv('https://api.deno.com/databases/YOUR_DATABASE_ID/connect');\n\n// do anything using the kv api: https://deno.land/api?s=Deno.Kv\u0026unstable\nconst result = await kv.set([ 'from-client' ], 'hello!');\nconsole.log(result);\n\n// close the database connection\nkv.close();\n```\n\n### Quick start - Bun\n_Use the [NPM package](https://www.npmjs.com/package/kv-connect-kit)_ 👉 `bun install kv-connect-kit`\n```ts\nimport { makeRemoteService } from 'kv-connect-kit';\n\nconst accessToken = Bun.env['DENO_KV_ACCESS_TOKEN'];\nif (accessToken === undefined) throw new Error(`Set your personal access token: https://dash.deno.com/account#access-tokens`);\n\n// make a local openKv function, optionally wrap unsupported serialized byte values as UnknownV8\nconst { openKv } = makeRemoteService({ accessToken, wrapUnknownValues: true });\n\n// open the database connection, use the url from project dashboard: https://dash.deno.com/projects/YOUR_PROJECT/kv\nconst kv = await openKv('https://api.deno.com/databases/YOUR_DATABASE_ID/connect');\n\n// do anything using the kv api: https://deno.land/api?s=Deno.Kv\u0026unstable\nconst result = await kv.set([ 'from-client' ], 'hello!');\nconsole.log(result);\n\n// close the database connection\nkv.close();\n```\n\n### Quick start - Node 18+\n_Use the [NPM package](https://www.npmjs.com/package/kv-connect-kit)_ 👉 `npm install kv-connect-kit`\n```ts\nimport { makeRemoteService } from 'kv-connect-kit';\nimport { serialize, deserialize } from 'v8';\n\nconst accessToken = process.env['DENO_KV_ACCESS_TOKEN'];\nif (accessToken === undefined) throw new Error(`Set your personal access token: https://dash.deno.com/account#access-tokens`);\n\n// make a local openKv function, on Node 18+ optionally pass full-fidelity V8 serializers to support all KV values\nconst { openKv } = makeRemoteService({ accessToken, encodeV8: serialize, decodeV8: deserialize });\n\n// open the database connection, use the url from project dashboard: https://dash.deno.com/projects/YOUR_PROJECT/kv\nconst kv = await openKv('https://api.deno.com/databases/YOUR_DATABASE_ID/connect');\n\n// do anything using the kv api: https://deno.land/api?s=Deno.Kv\u0026unstable\nconst result = await kv.set([ 'from-client' ], 'hello!');\nconsole.log(result);\n\n// close the database connection\nkv.close();\n```\n\n\n### Quick start - Node 14\n_Use the [NPM package](https://www.npmjs.com/package/kv-connect-kit)_ 👉 `npm install kv-connect-kit node-fetch`\n```ts\nimport { makeRemoteService } from 'kv-connect-kit'; // or: require('kv-connect-kit')\nimport fetch from 'node-fetch';\n\nconst accessToken = process.env['DENO_KV_ACCESS_TOKEN'];\nif (accessToken === undefined) throw new Error(`Set your personal access token: https://dash.deno.com/account#access-tokens`);\n\n// make a local openKv function, Node 14 does not provide a global `fetch` function, so pass a custom implementation like node-fetch\nconst { openKv } = makeRemoteService({ accessToken, fetcher: fetch });\n\n// open the database connection, use the url from project dashboard: https://dash.deno.com/projects/YOUR_PROJECT/kv\nconst kv = await openKv('https://api.deno.com/databases/YOUR_DATABASE_ID/connect');\n\n// do anything using the kv api: https://deno.land/api?s=Deno.Kv\u0026unstable\nconst result = await kv.set([ 'from-client' ], 'hello!');\nconsole.log(result);\n\n// close the database connection\nkv.close();\n```\n\n### Credits\n\n- Protobuf code generated with [pb](https://deno.land/x/pbkit/cli/pb/README.md)\n- NPM package generated with [dnt](https://github.com/denoland/dnt)\n\n\n---\n\n\n### Options to `makeRemoteService`\n\n```ts\nexport interface RemoteServiceOptions {\n    /** Access token used to authenticate to the remote service */\n    readonly accessToken: string;\n\n    /** Wrap unsupported V8 payloads to instances of UnknownV8 instead of failing.\n     * \n     * Only applicable when using the default serializer. */\n    readonly wrapUnknownValues?: boolean;\n\n    /** Enable some console logging */\n    readonly debug?: boolean;\n\n    /** Custom serializer to use when serializing v8-encoded KV values.\n     * \n     * When you are running on Node 18+, pass the 'serialize' function in Node's 'v8' module. */\n    readonly encodeV8?: EncodeV8;\n\n    /** Custom deserializer to use when deserializing v8-encoded KV values.\n     * \n     * When you are running on Node 18+, pass the 'deserialize' function in Node's 'v8' module. */\n    readonly decodeV8?: DecodeV8;\n\n    /** Custom fetcher to use for the underlying http calls.\n     * \n     * Defaults to global 'fetch'`\n     */\n    readonly fetcher?: Fetcher;\n\n    /** Max number of times to attempt to retry certain fetch errors (like 5xx) */\n    readonly maxRetries?: number;\n\n    /** Limit to specific KV Connect protocol versions */\n    readonly supportedVersions?: KvConnectProtocolVersion[];\n}\n```\n\n### A note about V8 serialization\n\n_All `KVKey` types are fully supported, as they don't use V8 serialization._\n\nDeno KV _values_ support any structured-serializable JavaScript values, using V8's internal serializer.  This makes client interaction from pure Javascript environment without access to V8 internals... tricky. \n\nA default V8 serializer is included that supports a limited subset of values (see below), but can optionally treat the values as opaque bytes using the `wrapUnknownValues` option.  This is often good enough for listing/migrating/logic that behaves on keys only.\n\nWe may be able to leverage [denoland/v8_valueserializer](https://github.com/denoland/v8_valueserializer) for a WASM implementation of V8's serializer in the future!\n\nKV value types supported by the default serializer:\n\n| Type      | Supported |\n| ----------- | ----------- |\n| `null`      | ✅       |\n| `undefined`   | ✅        |\n| `true`/`false`   | ✅        |\n| `Uint8Array`   | ✅        |\n| `string`   | ✅        |\n\nPRs to [v8.ts](https://github.com/skymethod/kv-connect-kit/blob/master/v8.ts) welcome - this would benefit everyone using this library!\n\nIf you have access to the V8 serializer on your runtime (like the `serialize`/`deserialize` in Node's `v8` module), you can pass it into the `encodeV8` and `decodeV8` options to get full value support.  Note you must be using the version that the Deno KV service uses, so this works on Node 18+ only.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskymethod%2Fkv-connect-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskymethod%2Fkv-connect-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskymethod%2Fkv-connect-kit/lists"}