Skip to content

iAPI Docs: Add client-side navigation guide under "Core Concepts"#75263

Merged
luisherranz merged 53 commits intotrunkfrom
docs/iapi-client-side-navigation-guide
Mar 3, 2026
Merged

iAPI Docs: Add client-side navigation guide under "Core Concepts"#75263
luisherranz merged 53 commits intotrunkfrom
docs/iapi-client-side-navigation-guide

Conversation

@DAreRodz
Copy link
Copy Markdown
Contributor

@DAreRodz DAreRodz commented Feb 5, 2026

What?

Adds a "Core Concepts" guide for the Interactivity Router.

Why?

The Interactivity Router, while being documented in the README, lacked an in-depth explanation about how it works.

How?

The document follows this structure:

  • Client-Side Navigation
    • How client-side navigation works
    • Getting started with the Interactivity Router
      • Setting up router regions
      • Implementing navigation
      • Implementing prefetching
      • Complete example: Pagination
    • Block compatibility
      • The supports.interactivity field
      • Non-interactive blocks
      • Interactive blocks using the Interactivity API
      • Interactive blocks using other libraries
    • More advanced use cases
      • Adding new regions on navigation
      • Handling server state updates
      • Overriding cached pages
      • Using custom HTML
      • Managing browser history
      • Changing the timeout
      • Handling fetch errors
      • Disabling client-side navigation on certain pages
      • Disabling navigation feedback
      • Subscribing to page changes
    • The Interactivity Router in depth
      • The page cache
      • Router regions
      • CSS handling
      • Script module handling
      • Server state and context
      • Putting it all together: the navigation flow
        • Phase 1: Prefetch (optional but recommended)
        • Phase 2: Navigate
        • Race condition protection
    • Full-page client-side navigation (experimental)

@DAreRodz DAreRodz added [Type] Developer Documentation Documentation for developers [Feature] Interactivity API API to add frontend interactivity to blocks. labels Feb 5, 2026
@DAreRodz DAreRodz marked this pull request as ready for review February 13, 2026 12:00
@DAreRodz DAreRodz requested a review from luisherranz February 13, 2026 12:01
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 13, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work so far, David! The guide is very well understood and covers a lot of topics.

For now, I've reviewed everything in depth up to the "Interactivity Router in depth" part, which I'll do on Monday, but that part looks very good too.

I'm adding a few comments here, and besides that, two other suggestions:

  • Adding a link to this guide in the interactivity-router README, prominently at the top, since there may be users who end up there and, in reality, should always read this guide.
  • Adding a section explaining that neither the scroll nor the focus are handled by the router, and that they are the responsibility of the action calling actions.navigate.

Comment on lines +31 to +33
```bash
npx @wordpress/create-block@latest my-interactive-block --template @wordpress/create-block-interactive-template
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juanmaguitar, weren't you working on a template for client-side navigation? Could it be?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may refer to the example I was working on for the block development examples:
https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-router-2f43f8

But it would be great to have a template for client-side-navigation. In fact, we could expand the existing @wordpress/create-block-interactive-template with a new variant for clien-side navigation (now it's easier because each variant can have its own structure of files #67768)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks Juanma 🙂

### Disabling navigation feedback

The Interactivity API router includes built-in feedback during navigation:
- **Loading animation**: A progress bar that appears during navigation.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to specify here what color is used for this bar, which I think is a CSS variable, like --color-primary or something like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting. Maybe we had it in the first versions and we forgot to copy it during some migration? I'll put it on the roadmap.

@github-actions github-actions bot added the [Package] Interactivity Router /packages/interactivity-router label Feb 16, 2026
@DAreRodz
Copy link
Copy Markdown
Contributor Author

@luisherranz, I think I've addressed all your feedback, including your suggestions:

  • A "Handling scroll and focus" section in 7c6987c.
  • A link to this guide inside the Router's README in e06e9ca.

Copy link
Copy Markdown
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some small changes in cc519b1, and here are some other suggestions for the in-depth part, which I think is quite good.

Apart from that, we should remove the section about block compatibility to do it separately and more carefully, and I wonder if we should also create a separate section for full-page client-side navigation.

Finally, I also wonder if we should remove most references to "interactive blocks" and blocks in general, since this also works with classic PHP themes.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 18, 2026

Flaky tests detected in 6f8f7d1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22636058579
📝 Reported issues:

@DAreRodz
Copy link
Copy Markdown
Contributor Author

@luisherranz, addressed your feedback. I'm doing an extra review of the whole document to make sure everything is fine.

Apart from that, we should remove the section about block compatibility to do it separately and more carefully, and I wonder if we should also create a separate section for full-page client-side navigation.

I removed the block compatibility section. Do you think we should start working on another document to explain block compatibility now?

Regarding full-page client-side navigation, do you mean a new document or a section in the same document? Asking because there's already a section at the end of the document.

Finally, I also wonder if we should remove most references to "interactive blocks" and blocks in general, since this also works with classic PHP themes.

Yup, we could emphasize somewhere in the document that client-side navigation works with classic themes as well.

@luisherranz
Copy link
Copy Markdown
Member

Do you think we should start working on another document to explain block compatibility now?

Yes.

Regarding full-page client-side navigation, do you mean a new document or a section in the same document? Asking because there's already a section at the end of the document.

I don't know, maybe it's fine as it is and we can move it in the future if it really deserves its own section.

Yup, we could emphasize somewhere in the document that client-side navigation works with classic themes as well.

Good idea. We could add a section at the beginning stating that it works with both blocks and classic themes. In fact, I'd like to make that much clearer throughout the documentation, as it currently seems like the Interactivity API only works with blocks.

In principle, here I think we should just delete all the sentences that talk about interactive blocks, which in a way assume that this only works in interactive blocks, and only leave the mentions of interactive blocks for things specific to them (supports.interactivity, etc.).

@juanmaguitar
Copy link
Copy Markdown
Contributor

juanmaguitar commented Feb 25, 2026

Apart from that, we should remove the section about block compatibility to do it separately and more carefully, and I wonder if we should also create a separate section for full-page client-side navigation.

What do you think about creating a new "Client Side Navigation" page under the iAPI docs root and inside of it another doc called "Block Compatibility Guide"

The new structure would like this:

Interactivity API Reference

  • Core Concepts
    • The Reactive and Declarative mindset
    • Understanding global state, local context, derived state and config
    • Server-side rendering: Processing directives on the server
    • Using TypeScript
  • Client Side Navigation 🆕
    • Block Compatibility Guide 🆕
  • Quick start guide
  • Directives and Store
  • About the Interactivity API
  • Frequently Asked Questions

Maybe this new "Client Side Navigation" page could also tackle #56638

@luisherranz
Copy link
Copy Markdown
Member

I love the idea. Maybe we could also include one about Full-page client-side navigation in the future.

@DAreRodz
Copy link
Copy Markdown
Contributor Author

I also like the idea. 😄

I think It would be a good opportunity to divide the guide (~1000 lines) in multiple documents.

@juanmaguitar, how would the structure be exactly? A folder named client-side-navigation with a README.md file containing the rest of the documents?

interactivity-api/
├── ...
└── client-side-navigation/
    ├── client-side-navigation-block-compatibility.md
    ├── client-side-navigation-in-depth.md
    ├── client-side-navigation-quick-start-guide.md
    ├── client-side-navigation-reference.md
    └── README.md

Copy link
Copy Markdown
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed some minor changes. It would be great if you could review it.

Apart from that:

  • We should include information about data-wp-key and how to use that directive so that lists work correctly when navigating.
  • We should also add information about how to inject data-wp-router-options='{"loadOnClientNavigation": true}' attribute using the PHP APIs (wp_interactivity()->add_client_navigation_support_to_script_module), and when it's automatically added (blocks with supports.interactivity).

@DAreRodz DAreRodz force-pushed the docs/iapi-client-side-navigation-guide branch from 469b49d to 6f8f7d1 Compare March 3, 2026 17:56
Copy link
Copy Markdown
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ❤️

Awesome work, David. This is a really, really good guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Interactivity API API to add frontend interactivity to blocks. [Package] Interactivity Router /packages/interactivity-router [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants