Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lit-routing

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lit-routing

A lightweight routing library for lit-html.

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Lit Routing 🔥

A lightweight wrapper for routing in lit-html apps. This library works with any routing library, if you provide a corresponding connector. A connector for the lightweight router Navigo is already provided.

Installing

Using npm:
npm i -S lit-routing

Using yarn:
yarn add lit-routing

Additionally, you need to install the routing library of your choice, e.g.:
npm i -S navigo
yarn add navigo

Usage

This library consists of a global Router object and a LitRouter component. First, you need to configure the router.

import {html} from 'lit-html';
import {Router, RouteConfig} from 'lit-routing';
import {NavigoConnector} from 'lit-routing/lib/connectors/navigo';

const routes: RouteConfig[] = [
  {path: '', template: document.createElement('button')},
  {path: '/settings', template: new SettingsPage()}, // <- suppose this is a LitElement / web component
  {path: '**', template: html`404 - not found`},
];

Router.initialize(NavigoConnector, routes, {useHash: true})

A route template can either be a lit-html template literal or a HTML element / web component. In order to provide a fallback route, a route with path '**' can be added as the last route.

Afterwards, you only need to use the <lit-router> element, where you want your routes to be displayed.

FAQs

Package last updated on 14 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc