> SvelteKit API Routes
Build server APIs and form handling in SvelteKit with load functions and actions.
fetch
$
curl "https://skillshub.wtf/skillshub-team/catalog-batch5/sveltekit-api?format=md"SKILL.md•SvelteKit API Routes
SvelteKit APIs
API Routes
// src/routes/api/posts/+server.ts
export async function GET() {
const posts = await db.post.findMany();
return json(posts);
}
export async function POST({ request }) {
const { title, body } = await request.json();
const post = await db.post.create({ data: { title, body } });
return json(post, { status: 201 });
}
Load Functions
// +page.server.ts
export async function load({ params }) {
return { post: await db.post.findUnique({ where: { slug: params.slug } }) };
}
Form Actions
export const actions = {
create: async ({ request }) => {
const data = await request.formData();
await db.post.create({ data: { title: data.get('title') } });
},
delete: async ({ request }) => {
const data = await request.formData();
await db.post.delete({ where: { id: data.get('id') } });
},
};
> related_skills --same-repo
> Nix Dev Shells with direnv
Auto-activate reproducible dev environments with Nix flakes and direnv.
> Dagger with GitHub Actions
Run Dagger CI/CD pipelines in GitHub Actions for portable, testable builds.
> Bun + Hono API
Build fast APIs with Bun runtime and Hono framework.
> Deno Fresh Framework
Build full-stack web apps with Fresh on Deno. Islands, routes, and zero runtime overhead.