Amphtml: amp-bind: Support title and URL change in AMP.pushState

Created on 27 Jul 2019  路  7Comments  路  Source: ampproject/amphtml

At history.pushState we can pass URL history.pushState(stateObj, title, URL); to change URL in browser without navigating away from page.

Could AMP implement it?

Ex.: In a SPA, an user select Tweets tab, and url change to /tweets, then select Agenda and url change to /agenda.

image

amp-bind When Possible Feature Request runtime

Most helpful comment

All 7 comments

@cvializ worthy to keep in mind as part of stateful AMP pages.

I think some aspects of this FR are already implemented in amp-bind with the AMP.pushState and AMP.popState actions. https://amp.dev/documentation/components/amp-bind/?referrer=ampproject.org#modifying-history-with-amp.pushstate()

But I believe it only allows the back/forward buttons to update the state, the URL and title are not updated at this time

That's correct. Also we'd need viewer coordination to update title and hash.

+1 At BringFido, title/url updating on state change (when not being shown from an amp cache) is the last mission-critical thing we can't pull off in AMP.

From an AMP-first perspective, many websites have a search/filter functionality which updates the URL so that it can be easily shared with filters pre-applied.

Similarly, all Shopify websites update the URL with ?variant={{variant.id}} so that when sharing a page with friends, the recipient auto-selects the proper variant.

If a user lands on a product page, clicks a new variant, and wants to share it with a friend, they'd likely share it by copying the address bar URL.

For websites that do URL updating, it does seem especially useful.

Is this intended on being implemented any time soon?
From what I gather above, it's currently deemed impossible?

Definitely possible, just hasn't been prioritized yet.

Similarly, all Shopify websites update the URL with ?variant={{variant.id}}

I think this can be done today with amp-list and a QUERY_PARAM variable substitution in the src attribute, though it would fire a network request.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

darobin picture darobin  路  48Comments

jasti picture jasti  路  50Comments

vockalimo picture vockalimo  路  49Comments

choumx picture choumx  路  113Comments

ericlindley-g picture ericlindley-g  路  117Comments