Skip to content

Instantly share code, notes, and snippets.

View elghaied's full-sized avatar
🏠
Working from home

Eslam ELGHAIED elghaied

🏠
Working from home
View GitHub Profile
@elghaied
elghaied / 1_Payload_V3_AutoRefreshSystem.txt
Last active August 11, 2024 19:18
Payload CMS v3 Auto-Refresh System
This Gist provides a complete implementation of an auto-refresh system for Next.js 14 applications using Payload CMS v3.
The system allows for real-time updates on the client-side when content is modified in the Payload CMS admin panel,
without requiring a full page reload or manual refresh.
Key Components:
1. Next.js **API Route** (auto-refresh/route.ts):
Implements a Server-Sent Events (SSE) system to maintain open connections with clients and broadcast refresh signals.