Intermediate20 min

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:

Terminal
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:

Terminal
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):

Terminal
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:

Terminal
#  Never do this
api_key = "sk-1234567890abcdef"

#  Always use secrets
api_key = os.environ['API_KEY']

Setting Up Secrets

  1. Click Tools in the sidebar
  2. Select Secrets
  3. Add key-value pairs:
    • Key: API_KEY
    • Value: sk-1234567890abcdef
  4. Click Add new secret

Accessing Secrets

Terminal
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
Terminal
// 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:

Terminal
import requests  # Replit installs automatically

Manual Installation

For explicit control:

Using the Packages Tool:

  1. Click ToolsPackages
  2. Search for package
  3. Click Install

Using the Shell:

Terminal
# 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:

Terminal
flask==2.3.0
requests>=2.28.0
sqlalchemy
python-dotenv

For Node.js, packages are in package.json:

Terminal
{
  "dependencies": {
    "express": "^4.18.0",
    "axios": "^1.4.0"
  }
}

The .replit File

Configure your Repl:

Terminal
# .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:

  1. Click Invite button
  2. Copy invite link
  3. Share with collaborators
  4. 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:

  1. Click Version Control in tools
  2. View change history
  3. Restore previous versions

Git Integration

For full version control:

Terminal
# 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:

  1. Create new Repl
  2. Select Import from GitHub
  3. Paste repository URL
  4. Replit clones and sets up

Development Tools

Debugger

Replit includes a debugger:

  1. Set breakpoints (click line numbers)
  2. Click Debug instead of Run
  3. Step through code
  4. Inspect variables

Console

Interactive Python/Node.js console:

Terminal
>>> 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:

Terminal
# 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()
Terminal
python -m pytest test_app.py

Web Server Configuration

Ports

Replit expects web apps on specific ports:

Terminal
# Flask
app.run(host='0.0.0.0', port=5000)
Terminal
// 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.co domains
  • 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:

  1. Click menu in file tree
  2. Select Upload file
  3. 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:

Terminal
# .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

Terminal
# 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.

Mark this lesson as complete to track your progress