An open API service indexing awesome lists of open source software.

https://github.com/aaronshaf/html-router

Drop-in router using web components
https://github.com/aaronshaf/html-router

custom-elements router web-components

Last synced: about 1 year ago
JSON representation

Drop-in router using web components

Awesome Lists containing this project

README

          

Drop-in router.

## Usage

### Hash router

```html

```

#### Render first match ([example](https://aaronshaf.github.io/html-router/examples/hash-switch.html))

```html


```

```html


Foo



Bar



Not found


```

#### Standalone routes ([example](https://aaronshaf.github.io/html-router/examples/hash-route.html))

```html


```

```html

Home

Foo

Bar

```

### Pathname router

```html

```

#### Render first match ([example](https://aaronshaf.github.io/html-router/examples/pathname-switch.html))

```html


```

```html


Foo



Bar



Not found


```

#### Standalone routes ([example](https://aaronshaf.github.io/html-router/examples/pathname-route.html))

```html


```

```html

Foo

Bar

```

## Access match params

Custom elements that are children of a route or switch can access match data at `this.match`.

## Prevent flash of undefined content

```html

hash-switch:not(:defined),
pathname-switch:not(:defined) {
visibility: hidden;
}

```

## Web components polyfill

```html

```

## See also

* [element-router](https://github.com/filipbech/element-router)