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';
import { files } from './files.ts';
const sources = await loadSources(files);
</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
Nested Islands Islands inside islands — a mochi:defer server island wrapping mochi:hydrate components, and a server island nesting both a deferred and a deferred-hydrated server island. View Transitions Drop <ViewTransitions /> into a shared layout to animate full-page navigations with zero JavaScript. Cookies Read and write cookies on the server and the client through one MochiCookieJar API.