Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rafaelindriago's avatar

Properties are not updated when use "back" button in browser using Livewire 3

Hello guys, following the docs: https://livewire.laravel.com/docs/url#storing-in-history

I want to use this feature for a search bar to a data table component, but when i use the "back" button, the query string is changed, but the components properties are not updated on backend or "snapshot", so the component is not rendered again with the property values in the query string... 😵

    use WithPagination;

    #[Url(history: true, except: '')]
    public $search = '';

    #[Url(history: true, except: [])]
    public $sortBy = [];

    #[Url(history: true, except: [])]
    public $filterBy = [];

Using @dump($this) i got the following:

  #__id: "aBjTYdP9kr5KX2J2vMrw"
  #__name: "user-data-table"
  #listeners: []
  #attributes: Livewire\Features\SupportAttributes\AttributeCollection {#620 ▶}
  #withValidatorCallback: null
  #rulesFromOutside: []
  #messagesFromOutside: []
  #validationAttributesFromOutside: []
  +search: ""
  +sortBy: []
  +filterBy: []
  +paginators: array:1 [▶]

The query string is updated if i search for something:

  #__id: "aBjTYdP9kr5KX2J2vMrw"
  #__name: "user-data-table"
  #listeners: []
  #attributes: Livewire\Features\SupportAttributes\AttributeCollection {#605}
  #withValidatorCallback: null
  #rulesFromOutside: []
  #messagesFromOutside: []
  #validationAttributesFromOutside: []
  +search: "[email protected]"
  +sortBy: []
  +filterBy: []
  +paginators: array:1 []

Then if i use the "back" button in browser, the $search property keeps with "[email protected]" 😐

Someone knows something about this? Maybe don't use this feature... Or "hook" into "popstate" event on JavaScript. 👀

0 likes
1 reply

Please or to participate in this conversation.