Last active
August 29, 2021 21:24
-
-
Save dcaponi/beb4c3790e2e76f8f28cfc62344aaea3 to your computer and use it in GitHub Desktop.
basic example of protected routes in svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- App.svelte --> | |
<script lang="ts"> | |
import { Router, Link, Route } from "svelte-routing"; | |
import ProtectedRoute from './concerns/ProtectedRoute.svelte'; | |
import Home from "./pages/Home.svelte"; | |
import SecretStuff from "./pages/SecretStuff.svelte"; | |
</script> | |
<Router> | |
<nav> | |
<Link to="/">Home</Link> | |
<Link to="secret">Secret Stuff</Link> | |
</nav> | |
<Route path="/"><Home /></Route> | |
<ProtectedRoute path="/secret" component="{SecretStuff}" /> | |
<Route path="/*" component={Home}/> | |
</Router> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment