How to use svelte-routing - 3 common examples

To help you get started, we’ve selected a few svelte-routing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github escalon / microfrontends / cart / server.js View on Github external
const path = require('path');
const express = require('express');
const { createHistory } = require('svelte-routing');

const history = createHistory('memory');

const server = express();

const app = require('./dist/ssr/bundle.js'); // require component

server.use(express.static(path.join(__dirname, 'dist')));

server.get('/cart/*', function(req, res) {
    history.replace(req.url);
    res.write(`
    
    <div class="grid grid--reverse" id="cart">${app.render()}</div> 
    
  `);
    res.end();
});
github stone-payments / pos-mamba-sdk / website / src / routes / history.js View on Github external
const listenAndCreateHistory = listen => {
  const history = createBrowserHistory()

  // Listen for changes to the current location.
  history.listen(() => {
    if (listen && typeof listen === 'function') {
      setTimeout(listen())
    }
  })

  setTimeout(history.listen(), 1000)
}
github escalon / microfrontends / cart / main.js View on Github external
import App from './CartApp.html';
import { createHistory } from 'svelte-routing';

createHistory('browser');

const app = new App({
    target: document.getElementById('cart'),
    hydrate: true
});

svelte-routing

A declarative Svelte routing library with SSR support

MIT
Latest version published 7 months ago

Package Health Score

75 / 100
Full package analysis