Deep Linking 🔗
Ever tried to share a link to a specific post on a social network, only to find that the link breaks when the post is moved or the server goes down?
We hate that.
That's why non-activity.stream uses deterministic deep linking based on content hashes.
How it Works
Every item in a <non-activity-stream> generates a stable, content-hashed ID using Multibase SHA-256.
When an item is rendered, its canonicalized JSON content is hashed. This hash becomes its unique identifier.
- Deterministic IDs: Generated using SHA-256, encoded as Multibase
base64url(prefixed withu). - Fragment Format:
#${streamId}/${itemId}or simply#${itemId}.
Why Content Hashes?
Because the ID is based on the content of the post, it's completely independent of any central server or database.
If you have the exact same ActivityStreams 2.0 JSON object on your local machine as someone else has on their Mastodon server, you both generate the exact same ID.
This means you can share a link to a post, and anyone with that post in their local database can open the link and see it, even if the original server is offline.
Interactive Highlighting
The <non-activity-stream> component reactively matches its own ID against the current location.hash in the browser URL.
If the hash matches an item in the stream, the component automatically sets the highlighted attribute on that item.
And because we render in the Light DOM, standard browser scrolling works out of the box. The targeted item is automatically scrolled into view using scrollIntoView.
No JavaScript routing required. Just standard web platform features, enhanced with cryptographic hashes.