Skip to content

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
@mjnaderi mjnaderi merged commit 6fc9c79 into develop May 21, 2025
32 checks passed
@mjnaderi mjnaderi deleted the nextjs-asgi-middleware branch May 21, 2025 03:43
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.

2 participants