0.1.1 • Published 5 years ago

osagai-simple-router v0.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

osagai-simple-router 🀄️®️

A simple and tiny (520 Byte) router implemented with Osagai

Install

npm install osagai osagai-simple-router

or import directly in your html using unpkg.com

<script src="//unpkg.com/osagai/osagai.umd.js"></script>
<script src="//unpkg.com/osagai-simple-router/dist/index.umd.js"></script>

Usage

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Osagai Simple Router</title>
</head>
<body>
  <div class="current-route"></div>
  <a href="/next">Go to next</a>

  <simple-router></simple-router>

  <script src="//unpkg.com/osagai/osagai.umd.js"></script>
  <script src="//unpkg.com/osagai-simple-router/dist/index.umd.js"></script>

  <script>
    const router = document.querySelector('simple-router')
    const currentRoute = document.querySelector('.current-route')

    router.addListener(route => {
      currentRoute.innerText = route
    });
  </script>
</body>
</html>