-
change how you access goto -- from:
import { goto } from "@sapper/app";
-- to:import { goto } from "$app/navigation";
-
change how you access sessions --from:
import { stores } from "@sapper/app";
const { session, page } = stores();
-- to:import { session, page } from "$app/stores";
-
preload is now load
-
this.redirect
<script context="module">
export async function load({ page, session, fetch, context }) {
return {
redirect: {
status: 302,
to: "/",
},
};
}
</script>
- this.error
<script context="module">
export async function load({ page, session, fetch, context }) {
return {
status: 402,
error: new Error("Unauthorized."),
};
}
</script>
- sapper.middleware = no more, so now it's
src/setup/index.js
:
export async function prepare(headers) {
let data= {};
// this gets called before every route, kind of like sapper.middleware
return {
context: {
data
}
}
};
export function getSession(context) {
// you can trim off sensitive data to send to client here
return {
data: context.data
}
};