Isomorphic URL
import { url } from 'mochi-framework' returns the current URL on both server and client. On the server it reads from the request context; on the client it reads from window.location. Try adding ?name=mochi to the URL.
SSR snapshot (server)
href
https://mochi.fast/demos/url/origin
https://mochi.fastpathname
/demos/url/search
(empty)hash
(empty) never sent to the serverHydrated island (server)
href
https://mochi.fast/demos/url/origin
https://mochi.fastpathname
/demos/url/search
(empty)hash
(empty) never sent to the server<script>
import UrlInfo from './UrlInfo.svelte';
</script>
<div class="sections">
<UrlInfo label="SSR snapshot" />
<hr />
<UrlInfo label="Hydrated island" mochi:hydrate />
</div>
Styles
<style>
.sections {
display: flex;
flex-direction: column;
gap: 1.2rem;
}
hr {
border: none;
border-top: 1px solid var(--border);
margin: 0;
}
</style>
More demos
View Transitions How view transitions work — drop <ViewTransitions /> into a layout to animate full-page navigations with zero JavaScript. Cookie Vary Test How cookie-partitioned caching works — a page that sets Vary: Cookie so responses key on cookies. Image: Named sizes How the image transform pipeline works — declare resize / rotate / flip / modulate / format as named sizes; getImageUrl mints a deferred URL, getImage runs one inline.