How to use the svelte-routing.createHistory function in svelte-routing

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 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 8 months ago

Package Health Score

72 / 100
Full package analysis