# FastAPI Lifespan Events are now supported on Vercel

**Published:** December 9, 2025 | **Authors:** Ricardo Gonzalez, Tom Lienard

---

Vercel now supports [lifespan events](https://fastapi.tiangolo.com/advanced/events/) for FastAPI apps. This allows you to define logic that can execute on startup and graceful shutdown—such as managing database connections or flushing external logs.

```python
from contextlib import asynccontextmanager
from fastapi import FastAPI

@asynccontextmanager
async def lifespan(app: FastAPI):
    # Startup logic
    print("Starting up...")
    await startup_tasks()
    yield
    # Shutdown logic
    await cleanup_tasks()

app = FastAPI(lifespan=lifespan)
```

Deploy FastAPI on Vercel or visit the [FastAPI on Vercel documentation](https://vercel.com/docs/frameworks/backend/fastapi).

---

📚 **More updates:** [View all changelog entries](/changelog/sitemap.md) | [Blog](/blog/sitemap.md)