Dave11235
Dave112356mo ago

Is it possible to connect to Deno KV from the browser?

I'm intrigued by the premise of Deno KV, but I'm having trouble understanding how it currently works. It's possible to access KV from Node on the server using the new Node package, but is it also possible to securely access KV directly from the browser, using a framework other than Fresh? Being able to do this would reduce the amount of code needed to add realtime functionality to my app significantly.
4 Replies
Deno AI Helper
Deno AI Helper6mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, I can provide some general insights. Deno KV is designed to be a global, low-latency key-value data store that can be accessed from server-side Deno scripts. Accessing Deno KV directly from the browser is not the intended use case, as it would require exposing your credentials to the client-side, which is a security risk. If you're looking to interact with Deno KV from the client side, the recommended approach would be to set up an API endpoint in your Deno server application that authenticates users and interacts with Deno KV on their behalf. This way, you can control access to the data store and keep your credentials secure. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. It's always a good practice to ensure that any interaction with a data store from the client side is done securely and with proper authentication and authorization checks in place.
Leokuma
Leokuma6mo ago
Deno KV can't be run in the browser What you can do is to host Deno KV in the server and make the browser connect to it. In order to do that, I believe you will need https://github.com/denoland/denokv and https://github.com/skymethod/kv-connect-kit
GitHub
GitHub - denoland/denokv: A self-hosted backend for Deno KV
A self-hosted backend for Deno KV. Contribute to denoland/denokv development by creating an account on GitHub.
GitHub
GitHub - skymethod/kv-connect-kit: Minimal Typescript client implem...
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. - GitHub - skymeth...
Dave11235
Dave112356mo ago
It's kv-connect-kit something you'd actually want to use in production though? It looks like you'd need to include your kv access token in whatever you're sending to the client, which seems like a bad idea.
Leokuma
Leokuma6mo ago
Probably I wouldn't use I would probably create HTTP endpoints protected by an auth mechanism, user privileges, business logic etc. Those endpoints would then perform specific tasks on Deno KV and respond to the browser