Server Islands Utilities
This integration provides a set of utilities to work with Astro’s Server Islands.
currentPageUrl
Type: (Astro: AstroGlobal) => URL
Extracts the URL of the current page from the Astro
context object, automatically taking into account whether the current component is being executed on a Server Island.
The Astro.url
property is not the URL of the page when running inside a server island. This function is a convenient wrapper that returns getServerIslandContext().pageUrl
when running on a Server Island and Astro.url
when not.
getServerIslandContext
Extracts information about the current execution in the context of a server island from the Astro
context object.
This function will return null
when not executing inside a Server Island (running directly on a page with no server:defer
in this component nor any parent component).
When running in the context of a Server Island, this function returns an object with the following properties:
pageUrl
Type: URL
The URL of the page where the component will be added to. This is the url of the top of the page, no matter how nested the server island is (a server island may return content including another server island).
License
Server Islands Utilities is available under the MIT license.