Query String
It can be useful at times to update the browser's query string when your component state changes.

Example

Let's say you are building a component to search articles, and want the query string to reflect the current search value like so:
https://yourapp.com/search-articles?search=some+string
This way, when a user hits the back button or bookmarks the page, you can get the initial state out of the query string rather than resetting the component every time.
You can add a queryString variable to your components and CBWIRE will update the query string every time the property value changes and also update the property when the query string changes.
component extends="cbwire.models.Component" {
data = {
"search": ""
};
queryString = [ "search" ];
}
<div>
<input wire:model="search" type="search" placeholder="Search articles...">
</div>
Export as PDF
Copy link