RazorWire JavaScript API
RazorWire JavaScript API
Public JavaScript contracts harvested from documented source comments.
window.RazorWire
SourceBrowser global that exposes RazorWire runtime managers and runtime configuration for diagnostics and advanced integrations.
window.RazorWirewindow.RazorWireIslandModules
SourceOptional island module manifest that maps logical `data-rw-module` names to approved module URLs before RazorWire imports them.
window.RazorWireIslandModules- Type: {Record<string, string>}
- Source: host page script or bundled app script
Properties
moduleNamestring - Logical island module name keyed by the value rendered in `data-rw-module`.
window.RazorWire.config
SourceRuntime configuration merged from the `<rw:scripts />` script tag.
window.RazorWire.config- Type: {object}
- Source: <rw:scripts />
Properties
developmentDiagnosticsboolean - Whether development diagnostics can be exposed.failureUxEnabledboolean - Whether failed-form request markers, events, fallback rendering, and diagnostics are enabled.failureMode"auto"|"manual"|"off" - Default failed-form behavior.defaultFailureMessagestring - Reader-facing fallback copy for unhandled form failures.
window.RazorWire.sectionCopyManager
SourceSection copy manager for framework-neutral section permalink buttons, generated copy controls, clipboard fallback UI, and lifecycle-safe rebinding.
window.RazorWire.sectionCopyManager- Type: {object}
- Source: <rw:scripts /> with rendered `[data-rw-section-copy]` or `[data-rw-section-copy-target]` markup
Properties
scanFunction - Re-scans the document for section-copy roots and markers after custom DOM updates.pruneFunction - Removes controllers for disconnected roots.getDiagnosticsFunction - Returns an array of stable section-copy diagnostic objects recorded since startup.getDiagnostics[].messagestring - Required reader-facing problem statement for the invalid marker or runtime state.getDiagnostics[].impactstring - Required explanation of the behavior RazorWire skipped, changed, or could not guarantee.getDiagnostics[].fixstring - Required remediation guidance suitable for docs, tests, and development diagnostics.getDiagnostics[].docsstring - Required repository documentation path for the related troubleshooting guidance.clearDiagnosticsFunction - Clears recorded section copy diagnostics.
razorwire:form:submit-start
SourceA RazorWire-enhanced form started submitting through Turbo.
razorwire:form:submit-start- Target: form[data-rw-form="true"]
- Fires when: Turbo begins submitting a RazorWire-enhanced form and RazorWire marks it busy.
- Bubbles: true
- Cancelable: false
Detail fields
detail.formHTMLFormElement - Submitted form.detail.submitterHTMLElement|null - Button or submit control that initiated the submission.
razorwire:form:failure
SourceA RazorWire-enhanced form submission failed and custom UI may handle the failure.
razorwire:form:failure- Target: form[data-rw-form="true"]
- Fires when: Turbo reports a failed form submission or RazorWire catches a network failure.
- Bubbles: true
- Cancelable: true
Detail fields
detail.formHTMLFormElement - Submitted form.detail.submitterHTMLElement|null - Button or submit control that initiated the submission.detail.statusCodenumber|null - HTTP status code when available.detail.handledboolean - Whether the server response already handled the failure.detail.responseKind"turbo-stream"|"html"|"json"|"unknown"|"network" - Failure category.detail.targetElement - Stream target or form that should own the failure UI.detail.messagestring - Reader-facing fallback message.detail.developmentDiagnosticObject|null - Development diagnostic payload when enabled.
razorwire:form:diagnostic
SourceDevelopment diagnostics are available for a failed RazorWire-enhanced form submission.
razorwire:form:diagnostic- Target: form[data-rw-form="true"]
- Fires when: development diagnostics are enabled for a failed RazorWire-enhanced form.
- Bubbles: true
- Cancelable: false
Detail fields
detail.formHTMLFormElement - Submitted form.detail.statusCodenumber|null - HTTP status code when available.detail.titlestring - Short diagnostic title.detail.detailstring - Diagnostic explanation.detail.docsHrefstring - Documentation link target.detail.hintsstring[] - Suggested fixes.
razorwire:form:submit-end
SourceA RazorWire-enhanced form finished submitting.
razorwire:form:submit-end- Target: form[data-rw-form="true"]
- Fires when: Turbo finishes a RazorWire-enhanced form submission or RazorWire handles a fetch error.
- Bubbles: true
- Cancelable: false
Detail fields
detail.formHTMLFormElement - Submitted form.detail.submitterHTMLElement|null - Button or submit control that initiated the submission.detail.successboolean - Whether the submission succeeded.detail.statusCodenumber|null - HTTP status code when available.detail.handledboolean - Whether the server response already handled the result.
razorwire:stream:error
SourceA RazorWire stream source reported a native EventSource error.
razorwire:stream:error- Target: rw-stream-source
- Fires when: The browser reports an EventSource error for a registered RazorWire stream source. Native EventSource does not expose HTTP status codes or response bodies to application JavaScript, so use server logs and the Network tab for exact rejection reasons.
- Bubbles: true
- Cancelable: false
Detail fields
detail.channelstring|null - Client-derived channel token for the stream source.detail.sourceElement - Stream source element that observed the error.detail.state"connecting"|"connected"|"disconnected"|string - Last RazorWire stream state before the error callback.detail.readyStatenumber - Native EventSource readyState value.detail.srcstring - Stream source URL.
data-rw-form
SourceEnables RazorWire form failure handling on a form.
data-rw-form- Target: form
- Type: {"true"}
data-rw-section-copy-root
SourceMarks an optional root that scopes section-copy status, generated buttons, feedback timers, and cleanup.
data-rw-section-copy-root- Target: section, article, main, div
- Type: {"true"}
data-rw-section-copy
SourceMarks a button that copies a section permalink for the referenced target id.
data-rw-section-copy- Target: button
- Type: {string}
data-rw-section-copy-title
SourceProvides reader-facing section title copy for `aria-label`, live status, and fallback dialog labels.
data-rw-section-copy-title- Target: button[data-rw-section-copy], [data-rw-section-copy-target]
- Type: {string}
data-rw-section-copy-status
SourceMarks an optional live status region for section-copy feedback.
data-rw-section-copy-status- Target: span, div
- Type: {"true"}
data-rw-section-copy-target
SourceMarks a heading or section container that should receive a generated plain-text copy button.
data-rw-section-copy-target- Target: h1, h2, h3, h4, h5, h6, header, section, div
- Type: {"true"}
scroll-padding-block
SourceLogical CSS inset contract for active page navigation reveal inside overflowing vertical nav surfaces.
scroll-padding-block- Target: visible vertical scrollable ancestor between `a[data-rw-page-nav-link]` and `[data-rw-page-nav]`
- Hook kind: css-property
- Stability: stable
scroll-padding-top
SourceStart-side CSS inset contract for active page navigation reveal inside overflowing vertical nav surfaces.
scroll-padding-top- Target: visible vertical scrollable ancestor between `a[data-rw-page-nav-link]` and `[data-rw-page-nav]`
- Hook kind: css-property
- Stability: stable
scroll-padding-bottom
SourceEnd-side CSS inset contract for active page navigation reveal inside overflowing vertical nav surfaces.
scroll-padding-bottom- Target: visible vertical scrollable ancestor between `a[data-rw-page-nav-link]` and `[data-rw-page-nav]`
- Hook kind: css-property
- Stability: stable
[data-rw-section-copy-enhanced="true"]
SourceStable selector for roots enhanced by the section-copy runtime.
[data-rw-section-copy-enhanced="true"]- Target: [data-rw-section-copy-root], body
- Hook kind: data-attribute
- Stability: stable
[data-rw-section-copy-inserted="true"]
SourceStable selector for generated section-copy buttons.
[data-rw-section-copy-inserted="true"]- Target: button[data-rw-section-copy]
- Hook kind: data-attribute
- Stability: stable
[data-rw-section-copy-state="copied|fallback"]
SourceStable selector for transient copy feedback state.
[data-rw-section-copy-state="copied|fallback"]- Target: button[data-rw-section-copy]
- Hook kind: data-attribute
- Stability: stable
[data-rw-section-copy-message]
SourceStable selector for generated section-copy feedback text attached to a button.
[data-rw-section-copy-message]- Target: button[data-rw-section-copy]
- Hook kind: data-attribute
- Stability: stable
[data-rw-section-copy-fallback="true"]
SourceStable selector for runtime-generated section-copy clipboard fallback UI.
[data-rw-section-copy-fallback="true"]- Target: generated fallback dialog
- Hook kind: data-attribute
- Stability: stable
[data-rw-section-copy-status-generated="true"]
SourceStable selector for runtime-generated section-copy status regions.
[data-rw-section-copy-status-generated="true"]- Target: generated status region
- Hook kind: data-attribute
- Stability: stable
data-rw-form-failure
SourceSelects how RazorWire renders unhandled form failures.
data-rw-form-failure- Target: form[data-rw-form="true"]
- Type: {"auto"|"manual"|"off"}
- Default: auto
[data-rw-form-error-generated="true"]
SourceStable selector for generated form failure UI.
[data-rw-form-error-generated="true"]- Target: generated form failure UI
- Hook kind: data-attribute
- Stability: stable
--rw-form-error-text
SourceControls generated form failure text color.
--rw-form-error-text- Target: [data-rw-form-error-generated="true"]
- Default: #3f3f46
- Syntax: <color>
mount
SourceIsland modules may export mount to hydrate a server-rendered root.
mount(root, props)- Target: module referenced by data-rw-module
- Signature: mount(root, props)
Parameters
rootHTMLElement - Island root element.propsRecord<string, unknown> - Parsed island props.
data-rw-module
SourceNames the browser module that should hydrate an island root.
data-rw-module- Target: [data-rw-module]
- Type: {string}
data-rw-strategy
SourceSelects when an island module hydrates.
data-rw-strategy- Target: [data-rw-module]
- Type: {"load"|"idle"|"visible"|"only"}
- Default: load
data-rw-props
SourceJSON props passed to an island module's mount function.
data-rw-props- Target: [data-rw-module]
- Type: {string}