Hi, I’m using AlexxNB/Tinro Router in my Meteor app but Guarded Routes are not working.
Can you help me understand what’s wrong in the following code?
<script>
import { writable } from "svelte/store";
import { Route } from "tinro";
const isLoggedIn = writable(false);
</script>
<Route path="/" redirect="/profile" />
{#if $isLoggedIn}
<Route path="/login/*" redirect="/profile" />
<Route path="/profile">
<h1>Welcome</h1>
<button on:click={() => ($isLoggedIn = false)}>Logout</button>
</Route>
{:else}
<Route path="/profile/*" redirect="/login" />
<Route path="/login">
<h1>Sign In</h1>
<button on:click={() => ($isLoggedIn = true)}>Sign In</button>
</Route>
{/if}
Also a simple “fallback” route doesn’t work:
<script>
import { Route } from "tinro";
</script>
<a href="/">Root</a>
<a href="/page">Page</a>
<a href="/blah">Not found</a>
<Route>
<Route path="/">Root page</Route>
<Route path="/page">Page</Route>
<Route fallback>Not Found</Route>
</Route>