Key-Value Store
A simple, built-in key-value database for your Replit Apps with no configuration required.
Replit Key-Value Store provides a simple, user-friendly database inside every Replit App. No configuration required—just import and start storing data immediately.
Features
- Zero configuration: Start using the database right away with no setup required
- Simple API: Store and retrieve data with an interface similar to Python dictionaries
- Multiple data types: Store strings, numbers, lists, dictionaries, and other Python objects
- Prefix filtering: Query for keys that share common prefixes
- Built-in access: Access your database from the Replit workspace sidebar
Getting started
Accessing your key-value store
How to access the Key-Value Store tool
How to access the Key-Value Store tool
From the left Tool dock:
- Select the second-to-last icon in the sidebar
- The Key-Value Store interface will appear with instructions and current data
You can also use the Search bar:
- Select the
magnifying glass at the top
- Type “Key-Value” to locate the tool
Importing the database
If you encounter deployment errors in Python, ensure you’re using replit
version 3.3.0 or above. Check your version with pip show replit
. Upgrade with upm add 'replit>=3.3.0'
.
For Node.js, make sure to install the package with pnpm add @replit/database
.
Using the key-value store
Creating and storing data
The Key-Value Store works similar to a dictionary in Python or an object in JavaScript. Here’s how to add data:
Storing different data types
Use 2D arrays/lists to create table-like structures:
Reading data
Retrieve data by referencing the key:
For safer access that won’t raise an error if the key doesn’t exist:
Listing and searching keys
Access all keys in the database:
Find keys with a specific prefix:
Updating data
Update stored values by assigning new values to existing keys:
Perform operations on stored values:
Deleting data
Remove key-value pairs:
Complete example
Here’s a complete example of using the Key-Value Store for a simple task list:
Use cases
The Key-Value Store is ideal for:
- User preferences: Store user settings and preferences
- Game state: Save game progress and high scores
- Caching: Store temporary data to speed up your application
- Simple configuration: Maintain configuration values across app restarts
- Session data: Track user sessions without complex database setup
FAQs
Where can I find my store?
Finding your Key-Value Store
Finding your Key-Value Store
When viewing your Replit App:
- Look for the Key-Value Store icon toward the bottom of the sidebar (second from last)
- Select it to open the database interface
How can I access my store programmatically?
Replit provides official clients for multiple languages:
Basic usage in different languages
Basic usage in different languages
What if my language doesn’t have a client?
If your Replit App is in a language without an official client, you can use HTTP requests to interact with the database:
HTTP API usage for custom clients
HTTP API usage for custom clients
Set a key-value pair:
Alternative set method (for safe characters):
Get a value:
Delete a key:
List keys with a prefix:
What is REPLIT_DB_URL?
REPLIT_DB_URL
is an environment variable created with your Replit App. It’s the connection string that enables database access.
REPLIT_DB_URL
provides full access to your database. Never expose it publicly or share it with untrusted parties.
How to access REPLIT_DB_URL
How to access REPLIT_DB_URL
In Deployments:
For deployed apps, the URL is stored in /tmp/replitdb
instead of the environment variable.
If writing a client, first check /tmp/replitdb
and fall back to the environment variable.
What are the storage limits?
The Key-Value Store has the following limits:
- 50 MiB per store (sum of keys and values)
- 5,000 keys per store
- 1,000 bytes per key
- 5 MiB per value
Rate limits apply to all operations. If exceeded, you’ll receive an HTTP 429 response. Implement exponential retry with gradual delays to handle rate limiting.
How can I check my storage usage?
Checking storage usage
Checking storage usage
- Open the Key-Value Store tool from the sidebar
- At the top of the interface, you’ll see your current usage:
- Number of keys in your store
- Total storage used by keys and values
Is my store private?
Yes, each store is private and isolated. Every Replit App has its own database that is not shared with other Replit Apps.
How do I share a database across multiple Replit Apps?
Creating a shared database service
Creating a shared database service
Next steps
To learn about other storage options available in Replit:
- SQL Database - For relational data with SQL queries
- Object Storage - For storing larger files and assets
- Secrets - For storing sensitive credentials securely