---
title: Dynamic Routing in Svelte
description: Learn how to enable dynamic rendering of new stories by setting up a catch-all route in Svelte.
url: https://storyblok.com/docs/guides/svelte/dynamic-routing
---

# Dynamic Routing in Svelte

Set up a catch-all route strategy in your Svelte project to render new stories dynamically.

## Fetch and render a story dynamically

Update the `+page.js` file to fetch all stories in the space.

src/routes/\[...slug\]/+page.js

```javascript
/** @type {import('./$types').PageLoad} */
export async function load({ params, parent }) {
  const { storyblokAPI } = await parent();

  const response = await storyblokAPI.get('cdn/stories/home', {
  const response = await storyblokAPI.get(`cdn/stories/${params.slug || 'home'}`, {
    version: 'draft',
  });

  return {
    story: response.data.story,
  };
}
```

Get the `slug` from the current route `params`, defaulting to the home story.

## Related resources

[Routing in Svelte](https://svelte.dev/docs/kit/routing)

[Content Delivery API: Retrieve a Single Story](/docs/api/content-delivery/v2/stories/retrieve-a-single-story)

[Content Delivery API: Retrieve Multiple Stories](/docs/api/content-delivery/v2/stories/retrieve-multiple-stories)

  

## Pagination

-   [Previous: Visual Preview in Svelte](/docs/guides/svelte/visual-preview)
-   [Next: Content Modeling in Svelte](/docs/guides/svelte/content-modeling)
