Tricks

Add render hooks to Filament plugins

Apr 29, 2023
Lara Zeus
Admin panel, Integration

If you're a Filament plugin developer, there is an easy way to allow your users to customize your package views without having to publish them.

Using the amazing feature that is already available in Filament core: RenderHook.

You can add this simple line in your blade file:

{{ Filament::renderHook('forms.before') }}

You can customize the hook's name as you need.

Now, everyone using your package will be able to use this hook the same as Filament hooks:

Filament::registerRenderHook(
'forms.before',
fn (): View => view('filament.hooks.forms-before'),
);

This way no need to publish the views files anymore, keep track of them, and update them with every release.

No comments yet…