- Learn
- AI App Builders
- Replit
- Replit Features for Developers
Explore Replit's development features including databases, secrets, packages, and collaboration tools.
Replit Features for Developers
Beyond AI assistance, Replit provides a full suite of development tools. This lesson covers the platform features that make serious development possible in the browser.
Database Options
Replit Database (Key-Value)
The simplest storage option—built into every Repl:
from replit import db
# Store data
db["user:123"] = {
"name": "Alice",
"email": "alice@example.com",
"score": 100
}
# Retrieve data
user = db["user:123"]
print(user["name"]) # Alice
# Delete data
del db["user:123"]
# List keys with prefix
users = [key for key in db.keys() if key.startswith("user:")]
Best for:
- Simple key-value storage
- Quick prototypes
- Small datasets
- Learning projects
Limitations:
- No SQL queries
- Limited to key-value patterns
- Size limits apply
SQLite
File-based SQL database:
import sqlite3
# Connect (creates file if doesn't exist)
conn = sqlite3.connect('app.db')
cursor = conn.cursor()
# Create table
cursor.execute('''
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
# Insert data
cursor.execute(
'INSERT INTO users (name, email) VALUES (?, ?)',
('Alice', 'alice@example.com')
)
conn.commit()
# Query data
cursor.execute('SELECT * FROM users')
users = cursor.fetchall()
Best for:
- Relational data
- Complex queries
- Prototypes before PostgreSQL
- Learning SQL
PostgreSQL
Full-featured database (requires setup):
import psycopg2
import os
# Connect using secrets
conn = psycopg2.connect(os.environ['DATABASE_URL'])
cursor = conn.cursor()
# Use like any PostgreSQL database
cursor.execute('SELECT * FROM users WHERE active = true')
Best for:
- Production applications
- Complex relationships
- Large datasets
- When you need full SQL
Secrets Management
Why Secrets Matter
Never put sensitive data in code:
# ❌ Never do this
api_key = "sk-1234567890abcdef"
# ✅ Always use secrets
api_key = os.environ['API_KEY']
Setting Up Secrets
- Click Tools in the sidebar
- Select Secrets
- Add key-value pairs:
- Key:
API_KEY - Value:
sk-1234567890abcdef
- Key:
- Click Add new secret
Accessing Secrets
import os
# Access environment variable
api_key = os.environ.get('API_KEY')
# With default fallback
debug_mode = os.environ.get('DEBUG', 'false')
# Check if secret exists
if 'DATABASE_URL' in os.environ:
# Connect to database
pass
// Node.js
const apiKey = process.env.API_KEY
// With fallback
const port = process.env.PORT || 3000
Secret Best Practices
- Use descriptive names:
STRIPE_SECRET_KEY,OPENAI_API_KEY - Never log secret values
- Rotate secrets periodically
- Use different secrets for dev/prod
Package Management
Automatic Installation
Replit often detects and installs packages:
import requests # Replit installs automatically
Manual Installation
For explicit control:
Using the Packages Tool:
- Click Tools → Packages
- Search for package
- Click Install
Using the Shell:
# Python
pip install requests flask sqlalchemy
# Node.js
npm install express axios dotenv
# View installed
pip list
npm list
Requirements Files
For Python, create requirements.txt:
flask==2.3.0
requests>=2.28.0
sqlalchemy
python-dotenv
For Node.js, packages are in package.json:
{
"dependencies": {
"express": "^4.18.0",
"axios": "^1.4.0"
}
}
The .replit File
Configure your Repl:
# .replit
run = "python main.py"
# Or for web apps
run = "flask run --host=0.0.0.0 --port=5000"
# Languages and settings
language = "python3"
entrypoint = "main.py"
# Environment
[env]
PYTHONDONTWRITEBYTECODE = "1"
Collaboration Features
Multiplayer Editing
Real-time collaboration:
- Click Invite button
- Copy invite link
- Share with collaborators
- Edit together—see each cursor
Collaboration Tips
- Use comments to communicate
- Establish code ownership for files
- Agree on coding style
- Use version control for history
Teams Features
For team projects:
- Team workspaces
- Shared secrets
- Access control
- Admin settings
Version Control
Built-in History
Replit automatically versions your code:
- Click Version Control in tools
- View change history
- Restore previous versions
Git Integration
For full version control:
# Initialize repo
git init
# Add files
git add .
# Commit
git commit -m "Initial commit"
# Connect to GitHub
git remote add origin https://github.com/user/repo.git
# Push
git push -u origin main
GitHub Import
Import existing projects:
- Create new Repl
- Select Import from GitHub
- Paste repository URL
- Replit clones and sets up
Development Tools
Debugger
Replit includes a debugger:
- Set breakpoints (click line numbers)
- Click Debug instead of Run
- Step through code
- Inspect variables
Console
Interactive Python/Node.js console:
>>> x = 5
>>> y = 10
>>> x + y
15
Linting
Code quality checking:
- Automatic error highlighting
- Style suggestions
- Quick fixes available
Testing
Run tests in your Repl:
# test_app.py
import unittest
from app import add
class TestAdd(unittest.TestCase):
def test_add_positive(self):
self.assertEqual(add(2, 3), 5)
if __name__ == '__main__':
unittest.main()
python -m pytest test_app.py
Web Server Configuration
Ports
Replit expects web apps on specific ports:
# Flask
app.run(host='0.0.0.0', port=5000)
// Express
app.listen(3000, '0.0.0.0', () => {
console.log('Server running')
})
The Webview
For web projects:
- Auto-refreshes on changes
- Shows at assigned URL
- Can open in new tab
- Works with hot reload
HTTPS
Replit provides automatic HTTPS:
- All apps get
*.repl.codomains - SSL certificates managed automatically
- Secure by default
File Management
Creating Files
- Right-click in file tree → New File
- Use shell:
touch newfile.py - AI Agent creates files automatically
Uploading Files
Drag and drop into the file tree, or:
- Click ⋮ menu in file tree
- Select Upload file
- Choose files from computer
File Limits
Be aware of limits:
- File size limits
- Total storage limits
- Some file types restricted
.gitignore
Exclude files from version control:
# .gitignore
__pycache__/
*.pyc
.env
node_modules/
.DS_Store
Performance Optimization
Resource Management
Monitor your Repl's resources:
- CPU usage
- Memory consumption
- Storage used
Optimization Tips
# Avoid in-memory accumulation
# ❌ Bad
all_data = []
for item in huge_dataset:
all_data.append(process(item))
# ✅ Better - use generators
def process_data(dataset):
for item in dataset:
yield process(item)
Boosted Repls
Paid features for more resources:
- More CPU
- More memory
- Faster execution
- Priority processing
Summary
Replit provides:
- Multiple database options: Key-value, SQLite, PostgreSQL
- Secrets management: Secure storage for API keys
- Package management: Easy installation and configuration
- Real-time collaboration: Multiplayer editing
- Version control: Built-in history and Git
- Development tools: Debugger, console, linting, testing
- Web server support: Automatic HTTPS and previews
Next Steps
You know Replit's features—now let's learn how to deploy and share your applications.