Some plugins are now available under Datastar Pro, which adds functionality to the the free open source Datastar framework. These plugins are available under a commercial license that helps fund our open source work.
Of the many changes listed below, one major feature is that objects in signals are now reactive! This means that you can now create complex data structures in signals, and any changes to these objects will automatically propogate to expressions.
SSE event handling has also changed, in addition to all of the SDKs. Please refer to the SSE docs and each of the SDKs for the correct syntax to use.
- Objects in signals are now reactive, meaning that any changes to these objects will automatically propogate to expressions.
- Plugins are now reapplied on morph only if their values/keys/modifiers have changed.
- Added the ability for Datastar to receive
text/html
,application/json
, andtext/javascript
content types, that patch elements, patch signals, and execute JavaScript respectively. - Added a
data-effect
attribute that executes an expression when any of the signals it references change. - Added a
data-ignore-morph
attribute to thePatchElements
watcher that skips morphing the respective element and its children. - Added a
data-json-signals
attribute that sets the text content of an element to a reactive JSON stringified version of all signals. - Added a
data-on-signal-patch
attribute that executes an expression when a signal patch takes place. - Added a
data-on-signal-patch-filter
attribute for filtering the signals that cause the expression indata-on-signal-patch
to be executed. - Added a
data-preserve-attr
attribute that preserves the client side state of an attribute through a morph. - Added a
data-on-resize
attribute (PRO) that attaches a ResizeObserver to the element, and executes the expression each time the element’s dimensions change. - Added a
data-query-string
attribute (PRO) that syncs the query string with signal values, including optional history support. - Added a
datastar-upload-progress
event (PRO) for monitoring file upload progress. - Added a
filterSignals
option to SSE actions that filters the signals send to the backend based on include and exclude regular expressions. - Added a
__trusted
modifier to thedata-on
attribute, which runs the expression even if theisTrusted
property on the event isfalse
. - Added automatic request cancellation for SSE actions - when a new request is initiated on an element, any existing request on that same element is automatically cancelled.
- Removed the
abort
option from SSE actions as request cancellation is now handled automatically at the element level. - The URL passed into SSE actions (
@get
,@post
, etc.) is now treated as a relative URI. - The default
Content-Type
header sent withform
requests is nowapplication/x-www-form-urlencoded
. - The value of a clicked button element is now included in the request when using the
form
content type. - The
data-star-ignore
attribute has been renameddata-ignore
. - The
data-attr
attribute now renderstrue
as""
instead of"true"
(e.g.checked=""
instead ofchecked="true"
). - The
data-attr
attribute now preserves the string literals"false"
,"null"
, and"undefined"
when using a key. - Fixed a bug when using the
__debounce.leading
modifier with thedata-on
attribute. - Removed the
data-on-signal-change
attribute. Use the newdata-on-signal-patch
attribute instead. - Removed the
datastar-signal-change
event. Use the newdatastar-signal-patch
event instead. - Removed the
includeLocal
option in backend action requests. Use thefilterSignals
option instead. - Removed the variable
ctx
from data attributes. Use the newel
variable to access the element the attribute is attached to, use the new$
variable to access the signal root, or the newdata-json-signals
attribute to output all signals. - Removed support for adding a dollar sign prefix to signal names in the value of the
data-bind
,data-ref
, anddata-indicator
attributes. - Removed the auto generated IDs that were assigned to elements using data attributes.
Changes to SSE Event Handling
- Renamed the
datastar-merge-fragments
anddatastar-merge-signals
SSE events todatastar-patch-elements
anddatastar-patch-signals
respectively. - Renamed the
mergeMode
parameter of thedatastar-patch-elements
SSE event tomode
. - Renamed the
morph
mode toouter
. - Renamed the
outer
mode toreplace
. - The
inner
mode now morphs the element’s inner HTML. - Removed the
upsertAttributes
mode. - Added the
remove
mode. - The
datastar-patch-signals
SSE event now patches (adds/updates/removes) signals according to the JSON Merge Patch RFC 7396. - Removed the
RemoveFragments
,RemoveSignals
, andExecuteScript
watchers.