Web development for the pythoniers
FluidKit provides tooling for building modern, highly optimized fullstack web applications with Python + the power of SvelteKit. Automatic type-safe client generation and environment-aware proxying make FastAPI + SvelteKit feel like a unified framework.
pip install fluidkit
Access the JavaScript ecosystem for UI while keeping all your business logic in Python. No Node.js backend knowledge required.
import fluidkit
fluidkit.integrate(app) # Generates portable TypeScript clients
import fluidkit
fluidkit.integrate(app, enable_fullstack=True) # Complete fullstack tooling
Prerequisites: Node.js, uv (preferred) or Poetry
# 1. Create SvelteKit project
npx sv create my-app
cd my-app
# 2. Initialize Python environment
uv init # or: poetry init
uv add fluidkit # or: poetry add fluidkit
# 3. Create Python backend
Folder structure:
src/
āāā routes/
ā āāā +page.svelte # Svelte component (frontend)
ā āāā hello.api.py # Python API logic (backend api for the frontend)
ā āāā hello.api.ts # Auto-generated by FluidKit
āāā app.py
Create src/app.py
:
import fluidkit
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
fluidkit.integrate(app, enable_fullstack=True)
if __name__ == "__main__":
import uvicorn
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)
Create src/routes/hello.api.py
:
from fastapi import APIRouter
from pydantic import BaseModel
router = APIRouter()
class Message(BaseModel):
text: str
@router.get("/hello")
async def get_message() -> Message:
return Message(text="Hello from Python!")
Use in src/routes/+page.svelte
:
<script>
import { get_message } from './hello.api';
let message = $state('');
get_message().then(result => {
if (result.success) message = result.data.text;
});
</script>
<h1>{message}</h1>
# 4. Start development
uv run python src/app.py # Start Python backend
npm run dev # Start SvelteKit (separate terminal)
You're ready! Visit http://localhost:5173
to see your full-stack app. Visit http://localhost:5173/proxy/docs
to see fastapi swagger UI.
Write your backend in Python:
from uuid import UUID
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class User(BaseModel):
id: UUID
name: str
email: str
@app.get("/users/{user_id}")
async def get_user(user_id: UUID) -> User:
# Your Python logic - database, validation, etc.
return fetch_user_from_database(user_id)
import fluidkit
fluidkit.integrate(app, enable_fullstack=True)
Use directly in SvelteKit like local functions:
<script>
import { get_user } from './users.api';
let userId = $state('');
let user = $state(null);
let error = $state('');
function loadUser() {
error = '';
get_user(userId).then(result => {
if (result.success) {
user = result.data;
} else {
error = result.error;
}
});
}
</script>
<input bind:value={userId} placeholder="Enter user ID" />
<button onclick={loadUser}>Load User</button>
{#if error}
<p style="color: red;">{error}</p>
{/if}
{#if user}
<div>
<h3>{user.name}</h3>
<p>{user.email}</p>
</div>
{/if}
FluidKit automatically generates:
// Full type safety from Python ā TypeScript
export interface User {
id: FluidTypes.UUID;
name: string;
email: string;
}
export const get_user = async (user_id: FluidTypes.UUID): Promise<ApiResult<User>> => {
// Environment-aware: direct FastAPI in SSR, proxied in browser
};
FluidTypes
namespacePerfect for existing projects, microservices, or when frontend/backend deploy separately:
# Generates portable TypeScript clients
fluidkit.integrate(app)
.fluidkit/
output directoryUnified Python + SvelteKit development with seamless integration:
# Enables complete fullstack tooling
fluidkit.integrate(app, enable_fullstack=True)
Guide | Description |
---|---|
Full-Stack Development | Complete SvelteKit integration, deployment, environment setup |
Streaming Clients | SSE, file downloads, JSON streaming patterns |
Configuration | Config reference, strategies, environments |
Auto-Discovery | File patterns, routing conventions, parameter validation |
Type System | FluidTypes namespace, external type handling |
Build modern, type-safe web applications using the Python ecosystem you know + the SvelteKit performance you want.