Replit enables coders to build apps quickly. With nothing but a browser, a developer can spin up a server, store data in Repl DB, and authenticate users using Repl Auth. However, until today, users had to string together all these components to build an app. This is why we're excited to announce replit.web, a Python framework focused on making apps quickly. Building an app with user auth and persistence has never been easier:

import flask
from replit import db, web

app = flask.Flask(__name__)
users = web.UserStore()

def index():
    hits = users.current.get("hits", 0) + 1
    users.current["hits"] = hits
    return f"You have visited this page {hits} times"

Repl Auth

Repl Auth is the built-in authentication system that ships with every Replit app. While Auth is super simple, it still required some code wrangling to integrate it into your app. Since replit.web extends the popular Flask web framework, authenticating a route is now as easy as using the web.authenticated decorator to require authentication. The current user is then accessible under

def index():
    return f"Hello, {}"

Repl DB

The magical experience of the new framework would not be possible without Repl DB -- the fully-managed cloud database that comes with every repl -- that provides the effortless persistence. DB can be used like a regular Python dictionary and it it even supports nested setting feature:

db["bob"] = {"score": 0}
db["bob"]["score"] += 100
db["bob"].get("friends", []).append("Alice")
print(db["bob"]) # => ObservedDict(value={'score': 100, 'friends': ObservedList(value=['Alice'])})

replit.web combines DB and Auth to provide web.UserStore, an instance of the db keyed by the usernames of authed users, which makes it straightforward to store user data:

users = web.UserStore() # optionally, pass a prefix

users.current # shorthand  for users[]

The fastest building experience

In addition to DB and Auth replit.web tries to make every aspect of web app development easier, including utilities such as ratelimiting and requiring parameters. To test out the framework, we decided to build ReplTweet, a fun Twitter clone for Replit users. Users can login, read tweets, like them, and tweet out their own thoughts. The whole application clocked in at 150 lines of code. You can give it a spin here, or follow the tutorial to build your own.

Our goal is for this framework to be the fastest way to make Python web apps. Right now, it's focused on small apps and prototyping. As with everything we do at Replit, this is an early release, and we'd be looking to you, our beloved community, to give us feedback on how we can improve it.

Please visit the docs to get started and if you build an app, make sure to add the hashtag #replitpy so we can see what you build. Let's get the hashtag trending!