8.11.1 • Published 4 years ago

navigo v8.11.1

Weekly downloads
20,493
License
MIT
Repository
github
Last release
4 years ago

Navigo

A simple dependency-free minimalistic JavaScript router

npm downloads size

Selling points

  • Dependency free
  • ~10KB minified, ~4KB gzipped
  • Based on History API so it does update the URL of the page
  • Supports hash based routing too
  • Simple mapping of route to a function call
  • Parameterized routes
  • Navigating between routes
  • Hooks (before, after, leave, already)
  • Not-found and default handler
  • Easy integration with HTML links via data-navigo HTML attribute

Installation

Drop the following into your page:

<script src="//unpkg.com/navigo"></script>

or via npm/yarn:

> npm install navigo --save
> yarn add navigo -S

Quick start

const router = new Navigo('/');

The constructor of the library accepts a single argument - the root path of your app. If you host your project at https://site.com/my/awesome/app, your root path is /my/awesome/app. Then you have to define your routes.

router.on('/products/list', function () {
  // do something
});

At the end you have to trigger the resolving logic:

router.resolve();

After that when you need a page change call the navigate method. This one changes the URL and (by default) triggers resolve.

router.navigate('/about');

Add data-navigo attribute to your page links and they'll be transformed into navigate callers.

<a href="/about/contacts" data-navigo>Contacts</a>

Checkout the online playground to see it in action.

Development

> yarn dev

Building

> yarn build

Tests

> yarn test
> yarn test-watch

MISC

8.11.1

4 years ago

8.11.0

4 years ago

8.10.0

4 years ago

8.10.1

4 years ago

8.9.1

4 years ago

8.9.0

4 years ago

8.8.12

4 years ago

8.8.11

4 years ago

8.8.10

4 years ago

8.8.9

4 years ago

8.8.8

4 years ago

8.8.7

4 years ago

8.8.6

4 years ago

8.8.5

4 years ago

8.8.4

4 years ago

8.8.3

4 years ago

8.8.2

4 years ago

8.8.1

4 years ago

8.8.0

4 years ago

8.7.2

4 years ago

8.7.3

4 years ago

8.7.1

4 years ago

8.7.0

4 years ago

8.6.5

4 years ago

8.6.4

4 years ago

8.6.3

4 years ago

8.6.2

4 years ago

8.6.1

4 years ago

8.6.0

4 years ago

8.5.0

4 years ago

8.4.4

4 years ago

8.4.3

4 years ago

8.4.2

4 years ago

8.4.1

4 years ago

8.4.0

4 years ago

8.3.2

4 years ago

8.1.1

4 years ago

8.3.1

4 years ago

8.2.0

4 years ago

8.3.0

4 years ago

8.1.0

4 years ago

8.0.1

4 years ago

8.0.0

4 years ago

8.0.0-beta.32

4 years ago

8.0.0-beta.31

4 years ago

8.0.0-beta.30

4 years ago

8.0.0-beta.29

4 years ago

8.0.0-beta.28

4 years ago

8.0.0-beta.27

4 years ago

8.0.0-beta.26

4 years ago

8.0.0-beta.25

4 years ago

8.0.0-beta.24

4 years ago

8.0.0-beta.23

4 years ago

8.0.0-beta.22

4 years ago

8.0.0-beta.21

4 years ago

8.0.0-beta.20

4 years ago

8.0.0-beta.19

4 years ago

8.0.0-beta.18

4 years ago

8.0.0-beta.17

4 years ago

8.0.0-beta.11

4 years ago

8.0.0-beta.13

4 years ago

8.0.0-beta.12

4 years ago

8.0.0-beta.15

4 years ago

8.0.0-beta.14

4 years ago

8.0.0-beta.16

4 years ago

8.0.0-beta.10

4 years ago

8.0.0-beta.9

4 years ago

8.0.0-beta.8

4 years ago

8.0.0-beta.7

4 years ago

8.0.0-beta.6

4 years ago

7.1.3

4 years ago

8.0.0-beta.5

4 years ago

8.0.0-beta.2

4 years ago

8.0.0-beta.1

4 years ago

8.0.0-beta.4

4 years ago

7.1.2

7 years ago

7.1.1

7 years ago

7.1.0

7 years ago

7.0.0

7 years ago

6.0.2

7 years ago

6.0.1

7 years ago

6.0.0

7 years ago

5.3.3

7 years ago

5.3.2

7 years ago

5.3.1

7 years ago

5.3.0

7 years ago

5.2.0

7 years ago

5.1.0

7 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.8.0

7 years ago

4.7.4

7 years ago

4.7.3

8 years ago

4.7.2

8 years ago

4.7.1

8 years ago

4.7.0

8 years ago

4.6.2

8 years ago

4.6.1

8 years ago

4.6.0

8 years ago

4.5.2

8 years ago

4.5.1

8 years ago

4.5.0

8 years ago

4.4.0

8 years ago

4.3.7

8 years ago

4.3.6

8 years ago

4.3.4

8 years ago

4.3.3

8 years ago

4.3.2

8 years ago

4.3.1

8 years ago

4.3.0

8 years ago

4.2.0

8 years ago

4.1.2

8 years ago

4.1.1

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.5.1

8 years ago

3.5.0

8 years ago

3.4.2

8 years ago

3.4.0

8 years ago

3.3.3

8 years ago

3.3.2

8 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.3.4

8 years ago

2.3.3

8 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.5

8 years ago

2.1.4

8 years ago

2.1.3

8 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.3.0

8 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.0

9 years ago