A comprehensive starter template for building full-stack Svelte applications with Firebase integration. This template includes authentication, blog functionality, marketing pages, and a basic app setup with sidebar navigation.
š View Documentation
Use this template by clicking "Use this template" on GitHub or fork the repository:
git clone https://github.com/YourUsername/svelte-firekit-starter.git
cd svelte-firekit-starter
Install dependencies:
npm install
Configure Firebase:
.env
file in the root directory:PUBLIC_FIREBASE_API_KEY=your_api_key
PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
PUBLIC_FIREBASE_PROJECT_ID=your_project_id
PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
PUBLIC_FIREBASE_APP_ID=your_app_id
Start the development server:
npm dev
āāā src/
ā āāā lib/
ā ā āāā components/ # Reusable components
ā ā āāā firebase/ # Firebase configuration
ā ā āāā utils/ # Utility functions
ā āāā routes/
ā ā āāā app/ # Protected application routes
ā ā āāā auth/ # Authentication pages
ā ā āāā blog/ # Blog pages
ā ā āāā +page.svelte # Landing page
ā āāā posts/ # MDsveX blog posts
āāā static/ # Static assets
āāā svelte.config.js # Svelte configuration
The template includes pre-built authentication flows:
/auth/signin
)/auth/signup
)/auth/forgot-password
)Protected routes are handled by the auth guard in src/routes/app/+layout.ts
.
// src/routes/app/+layout.ts
import { redirect } from '@sveltejs/kit';
import type { LayoutLoad } from './$types';
import { getUser } from '$lib/firebase/auth';
export const load: LayoutLoad = async ({ url }) => {
const user = await getUser();
if (!user) {
throw redirect(307, `/auth/signin?redirect=${url.pathname}`);
}
return { user };
};
The blog system uses MDsveX for Markdown processing and Shiki for code highlighting.
.md
file in src/posts/
---
title: "Your Post Title"
publishedAt: "2024-01-19"
author: "Your Name"
tags: ["svelte", "firebase", "typescript"]
excerpt: "Brief description of your post"
categories: ["Tutorial"]
featuredImage: {
url: "https://placehold.co/1200x630",
alt: "Featured Image Alt Text",
caption: "Image caption"
}
seo: {
title: "SEO-optimized title",
description: "SEO description for better search engine visibility",
keywords: ["keyword1", "keyword2", "keyword3"],
ogImage: "https://placehold.co/1200x630"
}
published: true
---
Your content here...
Code blocks are automatically highlighted using Shiki:
<script>
let count = 0;
</script>
<button on:click={() => count++}>
Count is {count}
</button>
The template uses ShadcN for UI components. Import components from $lib/components/ui
:
<script>
import { Button } from '$lib/components/ui/button';
</script>
<Button variant="default">Click me</Button>
The template uses Svelte FireKit for Firebase integration. Common operations:
import { signIn, signOut, createUser } from 'svelte-firekit/auth';
// Sign in
await signIn(email, password);
// Sign out
await signOut();
// Create user
await createUser(email, password);
npm build
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
For detailed documentation and guides, visit https://codebygio.com/libs/svelte-firekit-starter
This project is licensed under the MIT License - see the LICENSE file for details.