Skip to content

Add NextJsMiddleware #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Add NextJsMiddleware #38

wants to merge 6 commits into from

Conversation

mjnaderi
Copy link
Member

@mjnaderi mjnaderi commented May 17, 2025

This PR introduces an ASGI middleware that improves the Django-Next.js integration experience.

Key Improvements:

  1. Simplified Setup Process

    • Replaces the manual configuration of NextJSProxyHttpConsumer and NextJSProxyWebsocketConsumer with a single middleware: NextJsMiddleware.
    • Provides a clean, declarative approach for integrating Next.js with ASGI applications.
  2. Optimized Resource Management

    • Manages an aiohttp ClientSession throughout the application lifecycle using the ASGI lifespan protocol. The session is created during application startup and properly closed during shutdown, ensuring efficient reuse of HTTP connections when communicating with the Next.js server.
  3. Less Dependencies

    • Implements NextJsHttpProxy and NextJsWebSocketProxy as pure ASGI handlers instead of Django Channels consumers.
    • Deprecates old proxy handlers.
    • Removes channels from dependencies.

@mjnaderi mjnaderi requested a review from omidkazemi1 May 17, 2025 11:12
mjnaderi added 4 commits May 18, 2025 11:26
- Implement NextJSHttpProxy and NextJSWebsocketProxy as pure ASGI handlers instead of Django Channels consumers.
- Deprecate Django Channels consumers.
- Remove "channels" from dependencies.
@mjnaderi mjnaderi changed the title Add DjangoNextjsASGIMiddleware Add DjangoNextJsAsgiMiddleware May 19, 2025
@mjnaderi mjnaderi changed the title Add DjangoNextJsAsgiMiddleware Add NextJsMiddleware May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant