28 lines
714 B
JavaScript
28 lines
714 B
JavaScript
// https://vike.dev/onRenderClient
|
|
import { createApp } from './app.js';
|
|
|
|
// This onRenderClient() hook only supports SSR, see https://vike.dev/render-modes for how to modify onRenderClient()
|
|
// to support SPA
|
|
async function onRenderClient(pageContext) {
|
|
const { Page, pageProps } = pageContext;
|
|
|
|
if (!Page) {
|
|
throw new Error('Client-side render() hook expects pageContext.Page to be defined');
|
|
}
|
|
|
|
const app = createApp(Page, pageProps, pageContext);
|
|
|
|
app.mount('#app');
|
|
|
|
if (typeof window !== 'undefined') {
|
|
window.addEventListener('popstate', () => {
|
|
if (!window.location.hash) {
|
|
// force reload when back button is used
|
|
window.location.reload();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export { onRenderClient };
|