Sign Up" /> Sign Up" /> Sign Up"/>

Got to url on:click Sapper

6k views Asked by At

I want to link a button to a relative path in Sapper. Is there a better way than this?

<button onclick="window.location='signup';">Sign Up</button>
2

There are 2 answers

0
johannchopin On BEST ANSWER

If the purpose of this button is to only redirect the user to another page please directly use an anchor and style it as a button:

<a class="btn" href="/signup">Sign Up</a>

It will make your app more SEO friendly.

1
Maximus On
<script>
  import { goto } from '@sapper/app';
</script>

<button on:click={() => goto('/signup')}>Sign Up</button>