Anyone playing with @astro 5.14 and async rendering for @sveltejs? I'm trying to do what I thought would be a basic thing, grabbing an entry from my content collection (`await getEntry(‘collection’, 'item’)`) in my script tag, but I'm getting `Cannot await outside a <svelte:boundary> with a pending snippet` as an error, and the error URL 404s.

@snugug @astro @sveltejs can you clarify what you mean by „in my script tag“?

async Svelte in Astro works pretty well so far. I’ve tested these constellations and for islands I wrote some lines here: https://fubits.dev/notes/svelte-5-patterns-async-remote/#updates

@fubits @astro @sveltejs I'm doing something like:

<script>
import {getEntry} from 'astro:content';

const item = await getEntry('collection', 'item');

</script>

Server render only, want to use item throughout the component. Syntax may be off, on phone.

@snugug @astro @sveltejs just to confirm - you are doing that in a *.astro file, right?

And if yes - where is the async Svelte component being imported?

@fubits @astro @sveltejs No, I'm doing it in a Svelte file, trying to use the new async Svelte rendering to grab the content

@snugug @astro @sveltejs that’s a conceptual problem, not an async Svelte one.

Svelte is a frontend framework. Astro is a meta-framework like SvelteKit / Next / Nuxt.
Astro‘s content API belongs in Astro-land.

Frontend in Astro lives in client islands (unless wrapped in Server Islands).

You can only pass entries to Svelte (maybe even as a Promise) as props/children.

And pre-rendering would be tricky.

There’s an experimental API tho https://docs.astro.build/en/reference/container-reference/

Astro Container API (experimental)

Docs
@fubits @astro @sveltejs Thanks for your feedback here, but, I'm not quite sure it aligns with my current problem. Even using browser built-ins with the async rendering (specifically, fetch, as demonstrated in the Astro 1.4 release notes) fails with the "cannot use `await`…" error, so there's something else going on here before being able to determine whether it's possible to use Astro content APIs in my server-only Svelte component.

@snugug @astro @sveltejs hm, here’s a working example with async fetch and different client directives https://fubits.dev/svelte-async-server-island/

What helped me grok the relationship between Astro and async Svelte was starting with a very minimal example in StackBlitz. Maybe you could create a reproducible example of your bug.

Test: async Svelte & SSR in Astro - @fubits

Full Stack Developer specializing in Svelte, SvelteKit, Data Visualization, and Technical Project Management for NGOs and startups

fubits Portfolio
@fubits @astro @sveltejs Thanks for the follow-up. I'd encourage you to take a look at the links I've shared—your examples are great for _some_ of the uses of async rendered Svelte, but do not actually show what I'm interested and should be possible: top-level await in a server-only component.