You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support scoped server loaders for nested Pages layouts #882
Our admin layout displays an unread-report count shared by several nested pages. Middleware reads it before each request and puts it in shared. When a page action marks a report as read, the action’s page response still contains the pre-action count unless the handler refreshes it explicitly. Each action that changes the count has to know about the sidebar, and the admin-only field appears in the application-wide shared type.
What I checked
In a four-file React Pages fixture with void@1.11.0, I ran the installed page scanner with these files:
The page entry recorded serverPath: "admin/index.server.ts" and methods: ["loader"]. The layout entry recorded its directory and component path only. The Pages actions guide also documents that middleware does not run a second time when the action rerenders the page.
Request
Let a layout supply a server loader, for example through pages/admin/layout.server.ts, and expose the inferred result to that layout. Run it for requests that render a descendant page, including a page refresh after an action, so its data reflects the completed mutation. Pages outside that layout should incur no read. For the sidebar case this would let the layout own its count and let each page action own its mutation.
The existing workaround is to recompute the shared field in the action before returning, or redirect to make a fresh request.
Thanks, that works. The catch is that every page under admin/ has to compose loadSidebar into its loader, and one that forgets it shows a stale badge with no error. The count also still lands in the site-wide shared type. A layout.server.ts loader would put it in one place no page can miss, so I'll keep our current workaround until then.
Activity
hyfdev commentedon Nov 29, 2026
You can keep the count fresh today by computing it in middleware on each page loader under
admin/, instead of in application middleware.The loader runs again when an action rerenders the page, so it reads the count after the mutation:
The action doesn't need to know about the sidebar.
Pages outside
admin/never compute the count, and the field stays out of the app-wide shared type.The cost is that every page under the layout needs a loader with
loadSidebar, and you write theuseSharedtype by hand.karthickeyan-dev commentedon Nov 29, 2026
Thanks, that works. The catch is that every page under
admin/has to composeloadSidebarinto its loader, and one that forgets it shows a stale badge with no error. The count also still lands in the site-wide shared type. Alayout.server.tsloader would put it in one place no page can miss, so I'll keep our current workaround until then.