A component that needs server requests can declare its endpoints alongside its
assets and shared components. You do not need a separate route registration loop
in your package provider.
Declare an endpoint
Register the definition through the normal component registration API
during provider boot. FLEX registers declared routes once, after all component
providers have booted and the registry has frozen. Endpoint registration does
not load browser assets or render component HTML.
The generated name is filament-flex-fields.components.acme-widget.lookup.
The default prefix is flex-fields.
Keep routes in their own file
A route file returns a typed declaration list. It contains no Route::get() calls
and does not register endpoints as a side effect.
resources/routes/widget.php
Reference the file from your component definition:
resources/components/acme-widget.php
The same type, budget, duplicate-ID, authentication and collision checks apply
to inline declarations and declarations loaded from a file. This is trusted
package PHP; never accept route-file paths from browser input or saved schemas.
Controllers may live in src/Http/Controllers/ within the same package.
Share endpoints between components
When multiple components call the same server API, declare the endpoints on one
shared primitive and add that primitive to each consumer’s uses list. A
server-only primitive has no browser entry or styles:
Register all three definitions through your package’s normal registration API.
The routes are registered once for the installed component graph. Rendering two
fields does not register them twice, and sharing this primitive does not load the
other consumer’s CSS or JavaScript. FLEX’s Map Picker and Address Autocomplete use
this approach for their shared geocoding endpoints.
Controller and browser request
Pass the named route’s URL into the rendered instance configuration:
For requests protected by web, include Laravel’s CSRF token on writes.
Cancel browser requests with their field owner and reject stale responses.
Authentication identifies the user; your controller must still authorize each
record/tenant and validate the submitted payload.
Complete declaration reference
A definition accepts up to 32 endpoints; the registry accepts up to 4096 total.
Use a unique vendor/component prefix in names and paths.
Configuration and required protections
Your package configuration can supply:
Configured middleware cannot silently turn a private endpoint public or remove
its declared mandatory middleware. Trusted extension authors own controller
code and route definitions; this API is not a sandbox for untrusted PHP plugins.
Collisions and deployment
FLEX rejects duplicate route names and matching method/domain/path templates,
including templates that differ only in URI parameter names. It resolves configured
prefixes and validates controllers before adding any declared endpoints to the router.
A failed batch registration leaves the component registry unchanged.
Overlapping wildcard or custom-regex routes still require careful application
route design; the registry does not prove every possible regex intersection.
Controllers and route declarations support Laravel’s route cache. Cached routes
are used as-is on subsequent application boots. Refresh that cache whenever
component endpoints, middleware or prefix configuration change:
Only use declarations for stable server routes. Record IDs, tenant authorization
and optional per-instance behavior belong in the request/controller and rendered
configuration, not in a dynamically mutated definition. Last modified on October 17, 2026