rsc-kit/laravel
RSC Kit for Laravel brings server-driven component workflows to Laravel applications, with streamlined setup, routing, and rendering for reusable UI that keeps logic on the backend and cuts client-side JavaScript. Build faster, lighter interfaces while staying in familiar Laravel patterns.
Rsc facade, the package config, and any example route/controller.return Rsc::render('Dashboard', ['user' => $request->user()]);.Rsc::refuse(), which lets a server-side page/component refuse normal rendering while carrying structured data for the page. Start by adding one guarded branch — a policy check, feature flag, or tenant check — and confirm the frontend handles the refusal payload.Use Rsc::refuse($data) as an explicit page-level control-flow branch, not as an exception replacement:
if (! $user->can('view-dashboard')) {
return Rsc::refuse([
'reason' => 'forbidden',
'message' => 'You do not have access to this dashboard.',
]);
}
return Rsc::render('Dashboard', ['user' => $user]);
Keep refusal payloads small, stable, and JSON-serializable. Prefer a consistent shape such as reason, message, and optional data, and centralize it in an enum, DTO, or helper so frontend and backend agree.
Good day-to-day uses: authorization failures, feature-flag gates, onboarding/verification gates, unsupported tenant states, maintenance/read-only modes, and “not ready yet” page states that need data rather than a redirect.
Compose with Laravel’s normal request validation and policies before rendering. Let validation errors stay as validation errors; use Rsc::refuse() for page-render decisions.
Test both branches: a feature test for the normal RSC response and one for the refusal payload. Add a frontend/e2e check that the page actually renders the refusal state rather than a blank screen.
Rsc::refuse() is not an exception. Middleware and Laravel’s exception handler will not automatically catch it unless the package wires that up; return it explicitly from the controller/action.reason — not the full payload if it may contain user data.How can I help you explore Laravel packages today?