File Downloads

Livewire supports triggering file downloads for users with a simple, intuitive API.

To trigger a file download, you can return a Laravel file download from any component action.

class ExportButton extends Component
{
    public function export()
    {
        return Storage::disk('exports')->download('export.csv');
    }
}
<button wire:click="export">
    Download File
</button>

Livewire should handle any file download that Laravel would. Here are a few other utilities you might use:

return response()->download(storage_path('exports/export.csv'));
return response()->streamDownload(function () {
    echo 'CSV Contents...';
}, 'export.csv');
← Previous Topic

File Uploads

Next Topic →

Query String