🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@vanillarouter/router-module

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanillarouter/router-module

Vanilla JS routing package

latest
Source
npmnpm
Version
0.1.0-beta.7
Version published
Maintainers
1
Created
Source

Vanilla JS Routing package

This package is an angular-like routing package, only instead of Angular components, it renders a vanilla JS custom elements.

Use this package

installation

$ npm install @vanilarouter/router-module

Configuring toutes


import {Router} from '@vanillarouter/router-module';

const routes =   {path: '/', element: 'div', attributes: {is: 'images-container'}}
                   ,
                   {
                       path: '/addImage',
                       element: 'div',
                       attributes: {is: 'add-image'},
                       deactivateGuard: confirmExit
                   }, {
                       path: 'image/:index',
                       element: 'div',
                       attributes: {is: 'detailed-image'},
                       guard: imageExistGuard
                   }

Router.appRouter(routes);

// imageExistGuard and confirmExit are two custom functions you may write for handling route guards 

Routing anchor tags

<a title="Add image" is="self-routing-anchor" href="/addImage">Your text or content</a>

Router outlet

This is where the element are rendered according to the route You may use routes-animation-duration to animate route transitions It accepts number for duration in milliseconds.

<router-outlet routes-animation-duration="500"></router-outlet>

Progmatically navigate

Router.router.navigate('url')

Use route url-parameters

///  path: 'image/:index'
 const {currentSnapshot} = Router.router;
 const {index} = currentSnapshot.params;

Keywords

vanillajs

FAQs

Package last updated on 20 Nov 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