router-path

Utility to create router paths from a template and replaces the params.

Usage no npm install needed!

<script type="module">
  import routerPath from 'https://cdn.skypack.dev/router-path';
</script>

README

Utility function that replaces the params from a route template with the values of an object to create a valid route path. Designed for, but not limited to, React-router.

Example:

createPath('/foo/:bar', { bar: 'test' });

returns

'/foo/test'