Switching from Vercel KV to Upstash KV questions

Coming back to my Vercel template project after finishing up a side project, and noticed that Vercel KV is no longer available for new projects and Upstash KV is the new recommended default. I’ve deleted my Vercel KV DB and created a new Upstash KV DB and connected it with my project. I had a few questions about it as I’m going along.

URL protocol

From the new environment values populated, I see that the KV_URL is using rediss:// instead of redis://. Is that correct, or did I somehow get a typo? And if it is correct, what’s the reason for the change in protocol?

Package instance creation

One of the things I liked about the @vercel/kv package was not having to create an instance; as long as I had the right environment variables I could just directly call set/hset/etc. methods on the package. Looking at the @upstash/redis documentation, it looks like I have to manually create an instance and manage passing it around. Is there any alternative to that?

Other considerations

Is there anything else that might differ that I should pay mind to as I transition over? Any other notable changes to how I would use the package or how I interact with the DB?

Upstash KV support both rediss and redis protocol, you can choose either one: Build a Real-Time Chat Application with Serverless Redis - Upstash Documentation

Can you give us an example? Although I would ask to Upstash support team

There will be no changes in terms of pricing I believe. However, we might deprecate @vercel/kv in future and you need to use @upstash/redis to continue interact with KV databases

Ah so it’s the equivalent of https, got it. Should just be fine to use.

As an example, with @vercel/kv, I could do:

import { kv } from "@vercel/kv"

await kv.get('test')

But it seems that with @upstash/redis I have to do:

import { Redis } from "@upstash/redis"

const redis = new Redis({
  url: <URL>,
  token: <TOKEN>,
})

await redis.get('test')

I can make a singleton file for getting the instance, but definite downgrade that I have to manage that and set it up myself in every project. @vercel/kv exposed the createClient if you wanted to manage it yourself, which I think is a better way of doing it.

Ah makes sense. Since the SDK is managed by Upstash team, I would recommend to checking with them once and see if they have any suggestion.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.