secondsky/claude-skills / plugins/cloudflare-workers/skills/cloudflare-workers-frameworks
cloudflare-workers-frameworks
VerifiedFramework integration for Cloudflare Workers. Use when building with Hono, Remix, Next.js, Astro, SvelteKit, Qwik, or Nuxt on Workers. Covers routing, SSR, static assets, and edge deployment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.6 KB |
| references/astro.md | markdown | 8.7 KB |
| references/hono.md | markdown | 14.8 KB |
| references/nextjs.md | markdown | 10.2 KB |
| references/nuxt.md | markdown | 9.8 KB |
| references/qwik.md | markdown | 10.3 KB |
| references/remix.md | markdown | 13.3 KB |
| references/sveltekit.md | markdown | 10.4 KB |
| templates/astro-page.astro | other | 7.9 KB |
| templates/hono-app.ts | script | 7.2 KB |
| templates/nextjs-route.ts | script | 10.3 KB |
| templates/nuxt-server.ts | script | 14.1 KB |
| templates/qwik-route.tsx | other | 12.6 KB |
| templates/remix-loader.tsx | other | 10.0 KB |
| templates/sveltekit-route.ts | script | 10.7 KB |
templates/sveltekit-route.ts
View on GitHub/**
* SvelteKit Route Template for Cloudflare Workers
*
* Production-ready patterns for:
* - Server load functions
* - Form actions
* - API endpoints
* - Cloudflare bindings
*
* Usage:
* 1. Copy patterns to src/routes/
* 2. Configure svelte.config.js with cloudflare adapter
* 3. Set up wrangler.jsonc
* 4. Run: bun run dev
*/
// ============================================
// TYPE DEFINITIONS (src/app.d.ts)
// ============================================
/*
// src/app.d.ts
declare global {
namespace App {
interface Locals {}
interface PageData {}
interface PageState {}
interface Platform {
env: {
DB: D1Database;
KV: KVNamespace;
R2: R2Bucket;
ENVIRONMENT: string;
};
context: ExecutionContext;
caches: CacheStorage;
}
interface Error {}
}
}
export {};
*/
// ============================================
// SERVER LOAD FUNCTION (+page.server.ts)
// ============================================
import type { PageServerLoad, Actions } from './$types';
import { error, redirect, fail } from '@sveltejs/kit';
interface User {
id: number;
name: string;
email: string;
created_at: string;
}
// Load function - runs on server
export const load: PageServerLoad = async ({ params, platform, setHeaders }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
// If we have an ID parameter, load single user
if (params.id) {
const user = await DB.prepare('SELECT * FROM users WHERE id = ?')
.bind(params.id)
.first<User>();
if (!user) {
throw error(404, 'User not found');
}
// Set caching headers
setHeaders({
'Cache-Control': 'private, max-age=60',
});
return { user };
}
// Otherwise load user list
const { results: users } = await DB.prepare(
'SELECT * FROM users ORDER BY created_at DESC LIMIT 50'
).all<User>();
setHeaders({
'Cache-Control': 'private, max-age=30',
});
return { users };
};
// ============================================
// FORM ACTIONS (+page.server.ts)
// ============================================
export const actions: Actions = {
// Create user action
create: async ({ request, platform }) => {
if (!platform?.env) {
return fail(500, { error: 'Platform not available' });
}
const { DB } = platform.env;
const formData = await request.formData();
const name = formData.get('name') as string;
const email = formData.get('email') as string;
// Validation
const errors: Record<string, string> = {};
if (!name || name.trim().length === 0) {
errors.name = 'Name is required';
} else if (name.length > 100) {
errors.name = 'Name must be less than 100 characters';
}
if (!email || email.trim().length === 0) {
errors.email = 'Email is required';
} else if (!email.includes('@')) {
errors.email = 'Invalid email address';
}
if (Object.keys(errors).length > 0) {
return fail(400, { errors, values: { name, email } });
}
try {
// Check for existing email
const existing = await DB.prepare('SELECT id FROM users WHERE email = ?')
.bind(email.trim().toLowerCase())
.first();
if (existing) {
return fail(409, {
errors: { email: 'Email already exists' },
values: { name, email },
});
}
// Create user
const user = await DB.prepare(
'INSERT INTO users (name, email) VALUES (?, ?) RETURNING *'
)
.bind(name.trim(), email.trim().toLowerCase())
.first<User>();
return { success: true, user };
} catch (e) {
console.error('Create user error:', e);
return fail(500, { error: 'Failed to create user' });
}
},
// Update user action
update: async ({ request, params, platform }) => {
if (!platform?.env) {
return fail(500, { error: 'Platform not available' });
}
const { DB } = platform.env;
const formData = await request.formData();
const name = formData.get('name') as string;
const email = formData.get('email') as string;
// Validation
const errors: Record<string, string> = {};
if (!name || name.trim().length === 0) {
errors.name = 'Name is required';
}
if (!email || !email.includes('@')) {
errors.email = 'Valid email is required';
}
if (Object.keys(errors).length > 0) {
return fail(400, { errors });
}
try {
await DB.prepare('UPDATE users SET name = ?, email = ? WHERE id = ?')
.bind(name.trim(), email.trim().toLowerCase(), params.id)
.run();
return { success: true };
} catch (e) {
console.error('Update user error:', e);
return fail(500, { error: 'Failed to update user' });
}
},
// Delete user action
delete: async ({ params, platform }) => {
if (!platform?.env) {
return fail(500, { error: 'Platform not available' });
}
const { DB } = platform.env;
try {
await DB.prepare('DELETE FROM users WHERE id = ?').bind(params.id).run();
throw redirect(303, '/users');
} catch (e) {
if (e instanceof Response) throw e; // Re-throw redirect
console.error('Delete user error:', e);
return fail(500, { error: 'Failed to delete user' });
}
},
};
// ============================================
// API ENDPOINT (+server.ts)
// ============================================
/*
// src/routes/api/users/+server.ts
import type { RequestHandler } from './$types';
import { json, error } from '@sveltejs/kit';
interface User {
id: number;
name: string;
email: string;
}
export const GET: RequestHandler = async ({ platform, url }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
const limit = parseInt(url.searchParams.get('limit') || '10');
const offset = parseInt(url.searchParams.get('offset') || '0');
const { results } = await DB.prepare(
'SELECT * FROM users ORDER BY created_at DESC LIMIT ? OFFSET ?'
).bind(limit, offset).all<User>();
return json(results);
};
export const POST: RequestHandler = async ({ request, platform }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
const data = await request.json();
if (!data.name || !data.email) {
throw error(400, 'Name and email required');
}
const result = await DB.prepare(
'INSERT INTO users (name, email) VALUES (?, ?) RETURNING *'
)
.bind(data.name, data.email)
.first<User>();
return json(result, { status: 201 });
};
*/
// ============================================
// API ENDPOINT WITH ID (+server.ts)
// ============================================
/*
// src/routes/api/users/[id]/+server.ts
import type { RequestHandler } from './$types';
import { json, error } from '@sveltejs/kit';
export const GET: RequestHandler = async ({ params, platform }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
const user = await DB.prepare('SELECT * FROM users WHERE id = ?')
.bind(params.id)
.first();
if (!user) {
throw error(404, 'User not found');
}
return json(user);
};
export const PUT: RequestHandler = async ({ params, request, platform }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
const data = await request.json();
await DB.prepare('UPDATE users SET name = ?, email = ? WHERE id = ?')
.bind(data.name, data.email, params.id)
.run();
const user = await DB.prepare('SELECT * FROM users WHERE id = ?')
.bind(params.id)
.first();
return json(user);
};
export const DELETE: RequestHandler = async ({ params, platform }) => {
if (!platform?.env) {
throw error(500, 'Platform not available');
}
const { DB } = platform.env;
await DB.prepare('DELETE FROM users WHERE id = ?').bind(params.id).run();
return new Response(null, { status: 204 });
};
*/
// ============================================
// SVELTE COMPONENT (+page.svelte)
// ============================================
/*
<!-- src/routes/users/[id]/+page.svelte -->
<script lang="ts">
import type { PageData, ActionData } from './$types';
import { enhance } from '$app/forms';
export let data: PageData;
export let form: ActionData;
$: user = data.user;
</script>
<svelte:head>
<title>{user.name} | Users</title>
</svelte:head>
<div class="max-w-2xl mx-auto p-6">
<h1 class="text-2xl font-bold mb-6">{user.name}</h1>
{#if form?.success}
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
User updated successfully!
</div>
{/if}
{#if form?.error}
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
{form.error}
</div>
{/if}
<form method="POST" action="?/update" use:enhance class="space-y-4">
<div>
<label for="name" class="block text-sm font-medium">Name</label>
<input
type="text"
id="name"
name="name"
value={user.name}
class="mt-1 block w-full rounded border p-2"
required
/>
{#if form?.errors?.name}
<p class="text-red-600 text-sm mt-1">{form.errors.name}</p>
{/if}
</div>
<div>
<label for="email" class="block text-sm font-medium">Email</label>
<input
type="email"
id="email"
name="email"
value={user.email}
class="mt-1 block w-full rounded border p-2"
required
/>
{#if form?.errors?.email}
<p class="text-red-600 text-sm mt-1">{form.errors.email}</p>
{/if}
</div>
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded">
Update
</button>
</form>
<hr class="my-8" />
<form
method="POST"
action="?/delete"
use:enhance={() => {
return async ({ update }) => {
if (confirm('Are you sure you want to delete this user?')) {
await update();
}
};
}}
>
<button type="submit" class="px-4 py-2 bg-red-600 text-white rounded">
Delete User
</button>
</form>
</div>
*/
// ============================================
// SVELTE CONFIG
// ============================================
/*
// svelte.config.js
import adapter from '@sveltejs/adapter-cloudflare';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
routes: {
include: ['/*'],
exclude: ['<all>'],
},
platformProxy: {
configPath: 'wrangler.jsonc',
experimentalJsonConfig: true,
persist: '.wrangler/state',
},
}),
},
};
export default config;
*/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |