Install & Compatibility
Where this runs
tested against v1.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.7s · import 0.000s · 29MB
27MB installed
● package 27MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
lifespan
✓ from contextlib import asynccontextmanager
from starlette.applications import Starlette
@asynccontextmanager
async def lifespan(app):
# startup
yield
# shutdown
app = Starlette(lifespan=lifespan)
✗ app = Starlette(
on_startup=[startup_handler],
on_shutdown=[shutdown_handler]
) # on_startup/on_shutdown removed in 1.0
on_startup and on_shutdown parameters removed in 1.0. The lifespan context manager is the only supported pattern.
Route (declarative)
✓ from starlette.applications import Starlette
from starlette.routing import Route
async def homepage(request):
...
app = Starlette(routes=[Route('/', homepage)])
✗ @app.route('/')
async def homepage(request):
... # @app.route() decorator removed in 1.0
@app.route() and @app.websocket_route() decorators removed in 1.0. Use declarative Route() objects in the routes list.
Minimal Starlette 1.0 app with lifespan and declarative routing.
from contextlib import asynccontextmanager
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.routing import Route
@asynccontextmanager
async def lifespan(app):
# startup logic
yield
# shutdown logic
async def homepage(request: Request):
return JSONResponse({'hello': 'world'})
app = Starlette(
routes=[Route('/', homepage)],
lifespan=lifespan,
)
# Run: uvicorn main:app
Upgrade
Version history
1.6.0latest on PyPI · released Aug 8, 2026
Audit
Dependencies
anyio>=3.4.0,<5requiredAsync runtime abstraction. Required, installed automatically.
jinja2optionalRequired for Jinja2Templates. NOT auto-installed. Import now fails at import time if missing (changed in 1.0).
python-multipart>=0.0.7optionalRequired for form data and file uploads.
httpxoptionalRequired for TestClient. Replaced requests in 0.20.0.
itsdangerousoptionalRequired for SessionMiddleware.