#Can I use `fallback` slot in my Server Island component?

1 messages · Page 1 of 1 (latest)

ivory garden
#

I'm thinking about a "gated" content component that lets you gate certain content on the page. I'd like to have a fallback state that's "You need to log in" while it's loading AND if it loads and you're not logged in.

I tried just adding a slot area in the component with the name fallback to see if it would pull in, but it doesn't seem to... is there anything special about that name that would prevent that from being used in the component?

index.astro

<Gated server:defer>
                <Card
                    href="https://docs.astro.build/"
                    title="Documentation"
                    body="Learn how Astro works and explore the official API docs."
                />
                <Locked slot="fallback" />
            </Gated>

Gated.astro

<div>
    <slot name="fallback" /> 
</div>
wooden thistle
#

Yes, the slot name "fallback" tells the server island to show this content while the deferred content is loading

ivory garden
#

So it can't be used inside the component as an ordinary slot?

#

Also, any plans on adding a cache variable of some sort? I know that complicates things, so I know it would be a later feature, but curious if it's being roadmapped.

I'm building a tutorial creating a weather widget. the API only updates every 15 minutes, so it would be cool to add that as a piece of the server-side functionality to cache the html every 15 minutes