For using with VueJS, I suggest you to handle the Spatie methods only in the backend and pass the results as params to the VueJS views.
You can for example preload the medias with the model.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm building a project with Laravel, Vue and Inertiajs. In this project I'm allowing the user to upload product images. I want every image to be uploaded, converted to webp, optimized in size, generates responsive images and then displayed to the user. I figured that Spatie media library package can do that for me displaying responsive images part.
The only question is how to display responsive images in a Vue component. They provide helpers for blade components but I'm using Vue with Inertia.
The way they explained it in the docs for blade is like this:
{{-- in a Blade view --}}
<h1>My responsive images</h1>
{{ $yourModel->getFirstMedia() }}
So I'm wondering how can I pass this to a Vue component and make is parse HTML same as the package would do for a blade component.
For using with VueJS, I suggest you to handle the Spatie methods only in the backend and pass the results as params to the VueJS views.
You can for example preload the medias with the model.
Please or to participate in this conversation.