FastAPI 0.138.0 has been released, bringing a highly anticipated feature: native frontend serving via app.frontend() and router.frontend(). This new method simplifies serving static directories (e.g., "dist"), making it straightforward to host a Single Page Application (SPA) alongside your API.
Key changes in this release:
- New feature:
app.frontend("/", directory="dist")androuter.frontend("/", directory="dist")to mount static frontend files. Defined in PR #15800 by @tiangolo. See the updated Frontend docs. - Documentation fixes: Numerous typo corrections, broken link repairs, and whitespace adjustments across docs (PRs #15807, #15801, #15694 by @tiangolo and @YuriiMotov).
- Agent Library Skill: Instructions for
app.frontend()added to the Agent Library Skill (PR #15805). - Translations: Hindi docs translations are now enabled (PR #15554 by @YuriiMotov).
- Internal improvements: Fixed a failing test and updated error format (PR #15804), CI fix for
test-alls-green(PR #15803), enabled release notes typo checking (PR #15796), and updated translation script to usegpt-5.5model with-chatflag (PR #15792).
For developers, the app.frontend() addition eliminates the need for external tools or manual static file mounting when serving frontends. This is particularly beneficial for SPAs built with frameworks like React, Vue, or Angular, as it ensures clean URL routing and integrates seamlessly with FastAPI's existing path operations. The enhanced documentation and Hindi translation support also make the framework more accessible to a global audience.
Source: https://github.com/fastapi/fastapi/releases/tag/0.138.0