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
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?
How can I access my store programmatically?
Replit provides official clients for multiple 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:
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.
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?
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?
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