Skip to content

Search documentation

Find Svelte Patterns and Svelte reference pages.

No results for ""

Try a shorter query or a related Svelte term.

# Describe the problem

You’re looking to create a sitemap or a navigation menu and want an array of all the routes. SvelteKit provides a Pathname type that represents all possible routes, but it doesn’t provide a way to get a list of all routes at runtime.

# Solution

const modules = import.meta.glob('/src/routes/**/+page.svelte')
const routes = Object.keys(modules).map((key) =>
	key
		.replace('/src/routes', '')
		.replace('/+page.svelte', '')
		.replace('/(group)', ''),
)