Skip to content

Dynamic route missing +page.server.ts

A dynamic SvelteKit route ([slug]/+page.svelte) without a +page.server.ts has no server-side data loading. If the component fetches data client-side, Googlebot and AI crawlers receive the page shell with placeholder content instead of the actual page.

Create +page.server.ts in the same directory as +page.svelte. Export a load function that returns the data the page needs.

src/routes/blog/[slug]/+page.server.ts
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({ params }) => {
const post = await getPost(params.slug)
if (!post) error(404, 'Post not found')
return { post }
}
src/routes/blog/[slug]/+page.svelte
<script lang="ts">
import type { PageData } from './$types'
let { data }: { data: PageData } = $props()
</script>
<h1>{data.post.title}</h1>
<p>{data.post.excerpt}</p>

The load function runs on the server, so the data is present in the initial HTML response. Crawlers receive the full content.

Terminal window
curl https://yourdomain.com/blog/your-post-slug | grep '<h1'

Confirm the response body includes the actual post title. Then re-run orino audit.