Skip to content

Example for Vue

Since the routing library is a complex integration package that requires a server for SSR and work with the History API, Live Preview is unavailable. However, you can download ready-made examples.

Preview

src
components
pages
client.ts
declarations.d.ts
router.ts
server.ts
style.module.css
template.html
build.ts
package.json
tsconfig.json
ts
import { createApp, createSSRApp } from 'vue';

import App from './components/App.vue';
import { getRouter, routerStoreKey } from './router';

const router = getRouter();

await router.init(location.href, { skipLifecycle: Boolean(SSR_ENABLED) });

if (SSR_ENABLED) {
  createSSRApp(App, { router }).provide(routerStoreKey, { router }).mount('#example-app');

  console.log('SSR: App has been hydrated, no lifecycle called');
} else {
  createApp(App, { router }).provide(routerStoreKey, { router }).mount('#example-app');

  console.log('CSR: App has been rendered and lifecycle called');
}

Download

shell
npx degit dkazakov8/reactive-route/examples/vue vue-example
cd vue-example
npm install

Then choose the mode and reactivity system to run:

  • npm run vue — CSR (client-side rendering only) for Vue reactivity
  • npm run ssr-vue — SSR for Vue reactivity

No AI participated in the development. MIT License