Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/demonicious/svelte-static-hash-router

A Simple & Easy to use Static page router for Svelte.
https://github.com/demonicious/svelte-static-hash-router

Last synced: 6 days ago
JSON representation

A Simple & Easy to use Static page router for Svelte.

Awesome Lists containing this project

README

        

### Svelte Static Hash Router
A Simple & Easy to use Static page router for Svelte.
#### 1. Installation
It's available on NPM under the name 'svelte-static-hash-router'.
You can Install the package with the command below:

`npm i -D svelte-static-hash-router`

#### 2. Usage Example
```js

import Router from "svelte-static-hash-router/Router.svelte";
import Link from "svelte-static-hash-router/Link.svelte";

import Index from "./Components/Index.svelte";
import About from "./Components/About.svelte";
import ErrorComponent from "./Components/ErrorComponent.svelte";



```
The "Router" component needs to have a "routes" prop that is an array of Routes.

Each "Route" has a Path & and a Component. Optionally, You may pass "props" to the component which can be accessed with an "export let property_name" statement inside the Component.

The "Link" component needs to have a "to" prop that determines where the Link will go to.
You may specify any attributes for the Anchor tag by passing in a "attributes" prop as shown above.

#### 3. Notes
Currently this router can only be used for Static Routes. But I plan on making a Router for dynamic routes very soon.