// extract.js
import { array, define } from 'svelte-qparam'
import { boolean, number, string } from 'svelte-qparam/serde'
export const extract = define({
str: string,
num: number,
bool_array: array(boolean)
})
// +page.js
import { extract } from 'extract.js'
export const load = ({ url }) => {
const { values, qparams } = extract(url)
/* {
str: string;
num: number;
bool_array: boolean[];
} */
console.log(values)
return {
qparams
}
}
<!-- +page.svelte -->
<script>
export let data
$: ({ qparams } = data)
$: ({ str, num, bool_array } = qparams)
</script>
<output>
<code>load_str = {$str}</code>
<code>load_num = {$num}</code>
<code>load_bool_array = {JSON.stringify($bool_array)}</code>
</output>