Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire URL Query Parameters: Shareable States

Make your Livewire component states shareable with URL query parameters.

24 December 20251 min readLaravelاقرأ بالعربية

On this page

  1. Define URL Parameters
  2. Keep History
  3. Custom Parameter Name

Sync state with URL:

Define URL Parameters

php
use Livewire\Attributes\Url;

class SearchPosts extends Component
{
    #[Url]
    public $search = '';

    #[Url]
    public $category = 'all';
}

Keep History

php
#[Url(history: true)]
public $page = 1;

Custom Parameter Name

#[Url(as: 'q')]
public $search;

Users can bookmark and share filtered states!

All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read