Comments (7)
Since Vercel KV is based on the @upstash/redis
library, you can use Serverless Redis HTTP (SRH) to run a local HTTP endpoint for development. (See: https://docs.upstash.com/redis/sdks/javascriptsdk/developing-or-testing)
This is my current docker-compose.yml
setup:
version: '3.1'
services:
redis:
image: redis
ports:
- '6379:6379'
serverless-redis-http:
ports:
- '8079:80'
image: hiett/serverless-redis-http:latest
environment:
SRH_MODE: env
SRH_TOKEN: example_token
SRH_CONNECTION_STRING: 'redis://redis:6379' # Using `redis` hostname since they're in the same Docker network.
You can then connect with the following environment variables:
KV_REST_API_URL="http://localhost:8079"
KV_REST_API_TOKEN="example_token"
from edge-config.
Hey there, we're looking at adding pages for both postgres and kv about local development, will keep you posted
from edge-config.
Since Vercel KV is based on the
@upstash/redis
library, you can use Serverless Redis HTTP (SRH) to run a local HTTP endpoint for development. (See: https://docs.upstash.com/redis/sdks/javascriptsdk/developing-or-testing)This is my current
docker-compose.yml
setup:version: '3.1' services: redis: image: redis ports: - '6379:6379' serverless-redis-http: ports: - '8079:80' image: hiett/serverless-redis-http:latest environment: SRH_MODE: env SRH_TOKEN: example_token SRH_CONNECTION_STRING: 'redis://redis:6379' # Using `redis` hostname since they're in the same Docker network.You can then connect with the following environment variables:
KV_REST_API_URL="http://localhost:8079" KV_REST_API_TOKEN="example_token"
Thanks for your solution, I will try it out !
That would be good to have it in the doc as it was clearly an issue that kept me out of using this service on the first place.
from edge-config.
Since Vercel KV is based on the
@upstash/redis
library, you can use Serverless Redis HTTP (SRH) to run a local HTTP endpoint for development. (See: https://docs.upstash.com/redis/sdks/javascriptsdk/developing-or-testing)
Upstash developing or testing page has moved to: https://upstash.com/docs/oss/sdks/ts/redis/developing
from edge-config.
Hey there, we're looking at adding pages for both postgres and kv about local development, will keep you posted
any progress, @vvo ?
from edge-config.
Hey there, we're looking at adding pages for both postgres and kv about local development, will keep you posted
any progress, @vvo ?
Not being able to work offline is a deal breaker.
Being able to run tests offline is quite an important when developing an API.
from edge-config.
@0x33dm The docker container solution by @coreh above works as of 2024-04-20
. Simply download Docker desktop, and in your project directory root, create a file called docker-compose.yml
and copy & paste the contents:
version: '3.1'
services:
# This is the local Redis database that will be running on your computer; Within docker it has the hostname `redis` and it exposes the port 6379 to your pc and other containers
redis:
image: redis
ports:
- '6379:6379'
# This is the serverless router that allows the Vercel KV libraries to send queries to the redis server above (redis:6379)
# It uses the port 80 internally, so it is mapped to an arbitrary port 8079, so that it doesn't conflict with your potential web app on port 80
# Think of this as local Vercel KV, and you could even rename this to local-vercel-kv if that helps you to understand this structure
serverless-redis-http:
ports:
- '8079:80'
image: hiett/serverless-redis-http:latest
environment:
SRH_MODE: env
SRH_TOKEN: example_token # This is your local Vercel KV instance's API token (KV_REST_API_TOKEN), and you can change it to anything or keep it as is for development
SRH_CONNECTION_STRING: 'redis://redis:6379' # Using `redis` hostname since they're in the same Docker network.
Now when you have Docker Desktop (or other version of Docker) installed and running, simply open up a command line (bash/cmd/terminal) and navigate to the directory where you placed the docker-compose.yml
file, and execute the following command:
docker-compose up
Now you should see Docker downloading the needed images, and ultimately the local Vercel KV instance starts running.
Finally, within your project of choice, expose the 2 system variables required for the @vercel/kv library to connect to your local KV instance in a .env
file for example like above:
KV_REST_API_URL="http://localhost:8079"
KV_REST_API_TOKEN="example_token"
Hopefully this further explanation helps you out! This docker solution is the best one right now (and probably in the future) as you can deploy this locally on any operating system. If you have any questions, let me know.
As @tweeres04 kindly pointed out, you can also find a similar setup that will work with @vercel/kv in the Upstash documentation https://upstash.com/docs/oss/sdks/ts/redis/developing.
Vercel KV itself is simply a dumbed down wrapped version of Upstash, so generally anything that applies to Upstash will apply to Vercel KV. If you want to find out more, I'd suggest looking at what you get with Upstash directly instead of using Vercel KV as a wrapper. Disclaimer: I have nothing against Vercel KV, and use it in production
from edge-config.
Related Issues (20)
- [@vercel/postgres] - Error: VercelPostgresError - 'invalid_connection_string' using drizzle orm HOT 2
- x-axis visibility issue for extended columns in postgres table HOT 1
- [@vercel/postgres] - Error: syntax error at or near "$1" HOT 1
- pg.types.setTypeParser() not working with @vercel/postgres-kysely package HOT 1
- ReferenceError: TextDecoder is not defined While using blob storage in test cases HOT 3
- I have issue while integrating vercel blobs using server actions. HOT 4
- KV not flexible with Vercel Data Cache HOT 1
- hobby bandwidth limit HOT 1
- @vercel/blob `PutBlobResult.contentType` can be undefined
- Can't delete blob file. HOT 2
- Postgres: Cannot use type parser using `createPool` or `db.connect` HOT 1
- Vercel environment variable naming inconsistency with Vercel KV documentation HOT 1
- Broken Uploaded Images on Blob via Express Js HOT 2
- @vercel/blob - not possible to use `client` lib in node.js env HOT 8
- @vercel/blob - is it possible to cancel uploading a file? HOT 4
- @vercel/blob - Folder entry coming through as blob
- Upload/Download Progress on Vercel Blob HOT 4
- storage.put() is hanging in Deno HOT 1
- @vercel/postgres: How to connect to a localhost database for development work?
- `@vercel/blob` - Non descriptive error message when missing file extension HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edge-config.