Skip to main content
Ctrl+K
Litestar Framework - Home Litestar Framework - Home
Documentation
Community
Contributing
Learn how to contribute to the Litestar project
Code of Conduct
Review the etiquette for interacting with the Litestar community
Security
Overview of Litestar's security protocols
About
Litestar Organization
Details about the Litestar organization
Releases
Explore the release process, versioning, and deprecation policy for Litestar
Release notes
What's new in 2.0
2.x Changelog
1.x Changelog
Help
Discord Help Forum
Dedicated Discord help forum
GitHub Discussions
GitHub Discussions
Stack Overflow
We monitor the litestar tag on Stack Overflow
  • GitHub
  • Discord
Documentation
Community
Contributing
Learn how to contribute to the Litestar project
Code of Conduct
Review the etiquette for interacting with the Litestar community
Security
Overview of Litestar's security protocols
About
Litestar Organization
Details about the Litestar organization
Releases
Explore the release process, versioning, and deprecation policy for Litestar
Release notes
What's new in 2.0
2.x Changelog
1.x Changelog
Help
Discord Help Forum
Dedicated Discord help forum
GitHub Discussions
GitHub Discussions
Stack Overflow
We monitor the litestar tag on Stack Overflow
  • GitHub
  • Discord

Section Navigation

Documentation

  • Usage
    • Applications
    • Routing
      • Overview
      • Route handlers
      • Parameters
    • Requests
    • Caching
    • Channels
    • CLI
    • Databases
      • SQLAlchemy
        • SQLAlchemy Models & Repository
        • Plugins
      • Piccolo ORM
    • Debugging
    • Dependency Injection
    • Data Transfer Object (DTO)
      • Basic Use
      • AbstractDTO
      • Implementing Custom DTO Classes
    • Events
    • Exceptions and exception handling
    • HTMX
    • Life Cycle Hooks
    • Logging
    • Metrics
      • OpenTelemetry
      • Prometheus
    • Middleware
      • Using Middleware
      • Built-in middleware
      • Creating Middleware
    • OpenAPI
      • Configuring schema generation
      • OpenAPI UI Plugins
    • Plugins
      • Flash Messages
      • Problem Details
    • Responses
    • Security
      • Implementing Custom Authentication
      • Security Backends
      • Guards
      • Excluding and including endpoints
      • JWT Security Backends
      • Handling Secrets
    • Static files
    • Custom types
    • Stores
    • Templating
    • Testing
    • WebSockets
  • API reference
    • app
    • background_tasks
    • channels
      • plugin
      • subscriber
      • backends
        • base
        • memory
        • redis
        • psycopg
        • asyncpg
    • cli
    • config
    • connection
    • contrib
      • HTMX
      • jinja
      • jwt
      • mako
      • opentelemetry
      • piccolo_orm
      • pydantic
      • sqlalchemy
        • plugins
        • repository
        • types
        • base
        • DTO
    • controller
    • concurrency
    • data_extractors
    • datastructures
      • secret_values
    • di
    • dto
      • config
      • data_structures
      • field
      • types
      • base_dto
      • msgspec_dto
      • dataclass_dto
    • enums
    • events
    • exceptions
    • handlers
    • logging
      • config
      • picologging
      • standard
    • middleware
      • allowed_hosts
      • authentication
      • compression
      • cors
      • csrf
      • logging
      • rate_limit
      • session
        • base
        • client_side
        • server_side
    • openapi
      • openapi
      • plugins
      • spec
    • pagination
    • params
    • plugins
      • attrs
      • flash
      • htmx
      • problem details
      • prometheus
      • pydantic
      • structlog
      • sqlalchemy
    • repository
      • abc
      • filters
      • exceptions
      • testing
      • handlers
    • response
      • base
      • file
      • redirect
      • streaming
      • SSE (Server Sent Events)
      • template
    • router
    • routes
    • security
      • jwt
      • session_auth
    • serialization
    • static_files
    • status_code
    • stores
      • base
      • file
      • memory
      • redis
      • registry
      • valkey
    • template
    • testing
    • types
    • typing
  • Benchmarks

Guides

  • Migrating to Litestar
    • From Flask
    • From Starlette / FastAPI
  • Topics
    • Sync vs. Async
    • Deployment
      • NGINX Unit
      • Manually with ASGI server
      • Docker
      • Supervisor (Linux)
  • Tutorials
    • Developing a basic TODO application
      • Application basics
      • Accessing the list
      • Making the list interactive
      • Recap and assembling the final application
    • Improving the TODO app with SQLAlchemy
      • Introduction
      • Providing the session with DI
      • Using the serialization plugin
      • Using the init plugin
      • Final touches and recap
    • Data Transfer Object Tutorial
      • Our first DTO
      • Excluding from nested models
      • Excluding from collections of nested models
      • Max nested depth
      • Renaming fields
      • Receiving data
      • Read only fields
      • Accessing the data
      • Updating instances
      • Declaring DTOs on app layers
    • SQLAlchemy Repository Tutorial
      • Introduction to Database Modelling and Repository Features
      • Interacting with repositories
      • Working with Controllers and Repositories
      • Adding Additional Features to the Repository

Contributing

  • Contribution Guide
  • Available Issues
  • Usage
  • Routing

Routing#

Routing is a fundamental aspect of building web applications with Litestar. It involves mapping URLs to the appropriate request handlers that process and respond to client requests.

Litestar provides a flexible and intuitive routing system that allows you to define routes at various layers of your application.

Articles

  • Overview
    • Registering Routes
      • Registering routes dynamically
    • Routers
    • Controllers
    • Registering components multiple times
      • Controllers
      • Route handlers
    • Mounting ASGI Apps
  • Route handlers
    • Declaring paths
    • “reserved” keyword arguments
    • Type annotations
    • HTTP route handlers
      • Semantic handler decorators
    • Websocket route handlers
    • ASGI route handlers
      • Limitations of ASGI route handlers
    • Route handler indexing
    • Adding arbitrary metadata to handlers
    • Signature namespace
      • Default signature namespace
  • Parameters
    • Path Parameters
      • Supported Path Parameter Types
    • The Parameter function
      • Extra validation and documentation for path params
    • Query Parameters
      • Default values
      • Optional parameters
    • Type coercion
    • Alternative names and constraints
    • Header and Cookie Parameters
    • Layered Parameters

previous

Applications

next

Overview

© Copyright 2025, Litestar-Org.

Created using Sphinx 8.2.3.

Built with the PyData Sphinx Theme 0.16.1.