Skip to content

Components

All components use Svelte 5 snippets for their slot-like API. Import them from svelte-firekit.

Root provider component. Initializes Firebase, sets up Svelte context, and optionally enables App Check. Wrap your app (or root layout) with this component.

<FirebaseApp config={firebaseConfig}>
{@render children()}
</FirebaseApp>
PropTypeRequiredDescription
configFirebaseOptionsYesFirebase config object
appCheckOptionsAppCheckOptionsNoEnable App Check

Renders its children only when the user is signed in (and not anonymous).

<SignedIn>
<p>Only visible when signed in.</p>
</SignedIn>

No props.


Renders its children only when the user is not signed in.

<SignedOut>
<a href="/login">Sign in</a>
</SignedOut>

No props.


Conditionally renders content based on auth state and calls a callback when authorization fails.

<AuthGuard requireAuth={true} onUnauthorized={() => goto('/login')}>
<p>Protected content</p>
</AuthGuard>
PropTypeRequiredDescription
requireAuthbooleanYestrue to require sign-in; false to require sign-out
onUnauthorized() => voidNoCalled when the condition is not met

Runs async verification checks and renders content only when all pass.

<CustomGuard
verificationChecks={[
async () => {
const snap = await getDoc(doc(db, 'users', userId));
return snap.data()?.role === 'admin';
},
]}
onUnauthorized={() => goto('/403')}
>
<p>Admin-only content</p>
</CustomGuard>
PropTypeRequiredDescription
verificationChecksArray<() => Promise<boolean>>YesAsync functions that all must return true
onUnauthorized() => voidNoCalled when any check returns false

Reactive Firestore document subscription.

<Doc path="posts/my-post-id">
{#snippet data(post)}
<h1>{post.title}</h1>
{/snippet}
{#snippet loading()}
<p>Loading…</p>
{/snippet}
{#snippet error(err)}
<p>{err.message}</p>
{/snippet}
</Doc>
PropTypeRequiredDescription
pathstringYesFirestore document path
includeMetadataChangesbooleanNoListen to metadata changes
NameArgsRendered when
dataTDocument data is available
loadingFetching initial data
errorErrorSubscription fails
missingDocument does not exist

Reactive Firestore collection subscription.

<Collection path="posts" query={[where('published', '==', true)]}>
{#snippet data(posts)}
{#each posts as post (post.id)}
<article>{post.title}</article>
{/each}
{/snippet}
{#snippet loading()}
<p>Loading…</p>
{/snippet}
</Collection>
PropTypeRequiredDescription
pathstringYesFirestore collection path
queryQueryConstraint[]NoQuery constraints
NameArgsRendered when
dataT[]Collection data is available
loadingFetching initial data
errorErrorSubscription fails

Reactive Realtime Database node subscription.

<Node path="chat/messages">
{#snippet data(messages)}
<!-- messages is the raw RTDB value -->
{JSON.stringify(messages)}
{/snippet}
{#snippet loading()}
<p>Loading…</p>
{/snippet}
</Node>
PropTypeRequiredDescription
pathstringYesRTDB path
NameArgsRendered when
dataRaw RTDB valueData is available
loadingFetching initial data
errorErrorSubscription fails

Resolves a Firebase Storage download URL reactively.

<DownloadURL path="images/avatar.jpg">
{#snippet data(url)}
<img src={url} alt="Avatar" />
{/snippet}
{#snippet loading()}
<div class="skeleton" />
{/snippet}
</DownloadURL>
PropTypeRequiredDescription
pathstringYesStorage file path
NameArgsRendered when
datastring (URL)URL is resolved
loadingResolving URL
errorErrorURL cannot be resolved

Manages a resumable Storage upload.

<UploadTask path={`uploads/${file?.name}`} {file}>
{#snippet data({ progress, state, downloadURL, error })}
<progress value={progress} max={100} />
{#if downloadURL}<a href={downloadURL}>Download</a>{/if}
{/snippet}
</UploadTask>
PropTypeRequiredDescription
pathstringYesDestination Storage path
fileFileYesFile to upload
metadataSettableMetadataNoCustom metadata
NameArgsDescription
data{ progress, state, downloadURL, bytesTransferred, totalBytes, error }Upload state