DocsFirst steps
What is Nexy?
Nexy is a Python framework for fullstack web applications: your pages and your API live in one project and are served by one server.
What you get
- Pages in Python. A
.nexyfile is HTML with a few lines of Python on top; a.mdfile is a page too. No JavaScript is needed to render a page.
- An API in the same project. A
.pyfile undersrc/routes/answers HTTP requests: a function namedGETanswersGET, a function namedPOSTanswersPOST.
- An API in the same project. A controller answers HTTP requests: its method
getanswersGET, its methodpostanswersPOST, and a module groups controllers and their services.
- An API in the same project. The FastAPI router you already have keeps answering, and the
pages and route files of
src/routes/answer next to it.
- API documentation for free. Every API route appears in an OpenAPI schema, and Scalar shows it
as an interactive reference at
/docs. - Forms that call Python. A form, or a typed call from the browser, reaches the same Python function.
- A frontend framework when you want one. React, Vue, Svelte, Solid or Preact, for one component or for the whole site.
- One command to work, one to ship.
nx devreloads as you save;nx buildprepares production.
What it is built on
The current version, 2.2, stands on tools you may already know:
| Part | Built on | What it means for you |
|---|---|---|
| Server and API | FastAPI | an API route is a FastAPI route: Pydantic validation and dependencies work as usual |
| API reference | OpenAPI and Scalar | the schema is at /openapi.json, the reference at /docs |
| Pages | Jinja2 | a .nexy page uses Jinja2 tags such as {{ title }} |
| Frontend (optional) | Vite | only with a frontend framework, which also needs Node.js |
A first page and a first endpoint
A page, at /hello:
title: prop[str] = "Hello"<h1>{{ title }}</h1>An endpoint, at GET /api/items, listed at /docs without any extra code:
from nexy.http import Request async def GET(request: Request): return {"items": []}A view, and the controllers that answer /hello/ and GET /api/items/. The endpoint is listed at
/docs without any extra code, and a URL without its last slash redirects to it:
title: prop[str] = "Hello"<h1>{{ title }}</h1>from nexy.decorators import Controllerfrom nexy.hooks import useViews @Controller("/hello")class HelloController: async def get(self): return useViews("src/apps/hello_view.nexy", context={"title": "Hello"}) @Controller("/api/items")class ItemsController: async def get(self): return {"items": []}The root module lists them, and useRouter = AppModule in nexyconfig.py mounts it:
from nexy.decorators import Module from .hello_controller import HelloController, ItemsController @Module()class AppModule: controllers = [HelloController, ItemsController]What Nexy leaves to you
The database, the login and the rules about who may do what belong to your application, so you choose the libraries. Databases and Middleware and security show where each one plugs in.
Next steps
- Installation: install uv and create a project
- Quick start: run it, change a page, build it
- Core concepts: the few words the rest of the docs use