[wp-trac] [WordPress Trac] #64649: Interactivity API: Initialize router's `state.url` on the server
WordPress Trac
noreply at wordpress.org
Mon Feb 16 15:16:10 UTC 2026
#64649: Interactivity API: Initialize router's `state.url` on the server
-------------------------------+--------------------
Reporter: luisherranz | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 7.0
Component: Interactivity API | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------------+--------------------
The Interactivity API router currently initializes `state.url` on the
client using `window.location.href`. With the changes in Gutenberg PR
[https://github.com/WordPress/gutenberg/pull/70882 #70882], this
initialization was moved to a fallback pattern (`state.url = state.url ||
window.location.href`) so that the server can populate it first.
This ticket adds the server-side initialization of `state.url` in the
`core/router` namespace. The URL is set during the processing of the
`data-wp-router-region` directive, using the same pattern that WordPress
core uses internally to construct the current request URL (see
`redirect_canonical()` and `get_self_link()`):
{{{#!php
wp_interactivity_state(
'core/router',
array(
'url' => set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] .
wp_unslash( $_SERVER['REQUEST_URI'] ) ),
)
);
}}}
This enables proper server-side rendering of directives that reference
`state.url` in the `core/router` store.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64649>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list