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
Background jobs with queues How background job queues work — offload work to a Mochi.queue() with an embedded worker, no Redis. Reloading associated form data How reloading associated data works — after a successful submit, refetch the related list inside enhance(), or rely on the post-POST re-render. Form Redirects How form action redirects work — redirect(303, …) is intercepted as a JSON envelope by {@attach enhance(...)} or followed natively by the browser.