I get error message this when build.
Cannot access
url.searchParams
on a page with prerendering enabled
How to load and use get parameter?
svelte.config.js
import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';
const config = {
preprocess: preprocess({
}),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: null,
precompress: false
}),
prerender: {
default: true
},
trailingSlash: 'always'
}
};
export default config;
qna.svelte
...
import {page} from '$app/stores';
const id = $page.url.searchParams.get('id');
...