Skip to main content
Extensions are extra packages that add functionality to a Flask application. For example, an extension might add support for sending email or connecting to a database. Some extensions add entire new frameworks to help build certain types of applications, like a REST API.

Finding Extensions

Flask extensions are usually named “Flask-Foo” or “Foo-Flask”. You can search PyPI for packages tagged with Framework :: Flask. The best ways to learn about extensions are to look at how other extensions you use are written, and discuss with others. The Flask community is active on Discord Chat and GitHub Discussions.

Using Extensions

Consult each extension’s documentation for installation, configuration, and usage instructions. Generally, extensions pull their own configuration from app.config and are passed an application instance during initialization.

Basic Usage Pattern

For example, an extension called “Flask-Foo” might be used like this:
from flask_foo import Foo

foo = Foo()

app = Flask(__name__)
app.config.update(
    FOO_BAR='baz',
    FOO_SPAM='eggs',
)

foo.init_app(app)

The Application Factory Pattern

Extensions support the application factory pattern, allowing you to create the extension instance independently of the application:
from flask_foo import Foo

foo = Foo()

def create_app():
    app = Flask(__name__)
    app.config.update(
        FOO_BAR='baz',
        FOO_SPAM='eggs',
    )
    foo.init_app(app)
    return app
This pattern allows the extension instance to exist independently of the application, meaning other modules in your project can import and use the extension in blueprints before the app exists.

Extension Characteristics

Quality Flask extensions share common patterns:
  • Multiple Application Support: Extensions must support multiple applications running in the same Python process
  • Factory Pattern: Extensions should use the init_app() pattern for initialization
  • Configuration: Extensions pull configuration from app.config with keys prefixed by the extension name
  • Open Source: Extensions are typically licensed under BSD or MIT licenses
  • Documentation: Extensions should provide clear documentation and usage examples

Building Your Own Extension

While PyPI contains many Flask extensions, you may not find one that fits your need. If this is the case, you can create your own and publish it for others to use as well. See the Extension Development guide to learn how to develop your own Flask extension. The Flask ecosystem includes many high-quality extensions for common use cases. See the Popular Extensions page for a curated list of widely-used extensions.

Build docs developers (and LLMs) love