# How to redirect to a URL in Sapper

> Learn how to redirect to another URL in Sapper by calling this.redirect with a 301 status inside the preload function of your Svelte route module.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-08-06 | Topics: [Svelte](https://flaviocopes.com/tags/svelte/) | Canonical: https://flaviocopes.com/sapper-redirect-to-url/

I was working on a [Svelte](https://flaviocopes.com/svelte-getting-started/)+Sapper application when I had the need to redirect to a page, with URL `/spreadsheet/1`, when the user visited the root domain `/`, instead of showing the home page.

So I opened `src/routes/index.svelte`, removed everything in that file, and I added this code:

```js
<script context="module">
  export async function preload(page, session) {
    return this.redirect(301, 'spreadsheet/1')
  }
</script>
```
