As of now, Vercel has 4 different storage options.
Product | KV | Postgres | Blob | Edge Config |
Details | Durable Redis | Serverless SQL | Large file storage | Global, low-latency data store |
Reads/Writes | Fast/ms | Fast/ms | Fast/ms | Ultra-fast (~5ms - ~15ms) /s |
Use Case | Key/value and JSON data | Structured, relational data | Large, content-addressable files ("blobs") | Runtime configuration (e.g., feature flags) |
Advantages
- Incredibly fast to read. Lookups return in 5 ms or less, and 99% of reads will return under 15 ms.
- Do not need to perform a deployment.
- Global, available in all regions
Use Cases
- Feature flags and A/B testing
- Enabling maintenance pages or critical redirects
- Malicious IP and User Agent blocking
Details
- Should not be used as a general-purpose key/value store. Use KV instead.
- Cost is mostly depends on the reads as the primary use case of Edge Config is reading data at the edge. Number of writes also matters in overall pricing.
- Important to note that the maximum store size of all the key value data is 64KB. So it is limited to only critical data which needs to be in edge for quicker read.
- Takes 10 seconds to propagate the changes in key-value data to global regions.
- There are costs and limits to the number of reads and writes per plan so I would recommend using it when there is a feature release, soft launching a feature to a limited group or similar tasks. Once done, it should be removed to avoid any charges.
Edge Config SDK and API
- Edge Config connection string should be added in the environment variable with key EDGE_CONFIG. By default, SDK reads the connecting string from the environment variable.
- An SDK to read data from Edge Config API is available. @vercel/edge-config. Install the npm package using
- get - Reading a value
- has - Checking if a key exists
- getAll - Reading all items or in batches
Use Case 1: Redirect
In case if you have a feature update on certain section of a site and you would like to enable maintenance page and need a way to quickly remove it without any deployment, you can add the flag in the Edge config and use it to rewrite the section of the site to maintenance page using middleware.
Refer this demo page: Use case 1. https://nextjs-edgeconfig.vercel.app/
Use Case 2: Feature Flags
In case if a feature should be enabled or disabled with a feature flag, Edge Config can help in changing the response. This should eventually removed once the feature has been permanently enabled to avoid Edge Config read hits.
Similarly there are many uses cases where the edge data can be used. Another reminder that this edge config is not for regular key-value data as there are restrictions to the size and the number of read/write hits.