I wanted one of my route in my app not to be server side rendered.
The way to do this will be doing export const ssr = false
in module script or setting ssr: false
in svelte.config.js
as mention in svelte docs
But even after disabling ssr in both the ways, I'm still getting errors in terminal like localStorage is not defined
which should be not there with ssr disabled.
While app still works find. But whenever i reload the page in browser this error appears on the terminal
[vite] Error when evaluating SSR module /src/routes/index.svelte:
ReferenceError: localStorage is not defined
svelte.config.js
import preprocess from 'svelte-preprocess';
import adapter from '@sveltejs/adapter-static';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
ssr: false,
adapter: adapter({
fallback: '200.html'
}),
prerender: {
enabled: false
},
}
};
export default config;
index.svelte
<script context="module" lang="ts">
export const ssr = false
</script>
<script lang="ts">
import Yrtc from "./../helpers/Yrtc";
import { onMount } from "svelte";
onMount(() => {
const yrtc = new Yrtc({
roomId: 'tet-riieiiasds-di'
})
console.log({yrtc})
})
</script>
test