Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 2.01 KB

File metadata and controls

73 lines (48 loc) · 2.01 KB

@objectstack/sveltekit

SvelteKit adapter for ObjectStack — server endpoints and handle hook for the auto-generated REST API.

npm License: Apache-2.0

Overview

Bridges SvelteKit request events to HttpDispatcher. Ship ObjectStack either as a catch-all +server.ts route or as a handle hook for global interception.

Installation

pnpm add @objectstack/sveltekit

Quick Start — catch-all endpoint

// src/routes/api/[...path]/+server.ts
import { createRequestHandler } from '@objectstack/sveltekit';
import { kernel } from '$lib/server/kernel';

const handler = createRequestHandler({ kernel });

export const GET = handler;
export const POST = handler;
export const PUT = handler;
export const PATCH = handler;
export const DELETE = handler;

Global handle hook

// src/hooks.server.ts
import { sequence } from '@sveltejs/kit/hooks';
import { createHandle } from '@objectstack/sveltekit';
import { kernel } from '$lib/server/kernel';

export const handle = sequence(createHandle({ kernel, prefix: '/api' }));

Key Exports

Export Kind Description
createRequestHandler(options) function Returns a RequestHandler for catch-all routes.
createHandle(options) function Returns a SvelteKit Handle hook.
SvelteKitAdapterOptions interface { kernel, prefix? }.

When to use

  • ✅ SvelteKit 2.x applications.
  • ✅ Projects preferring the handle hook over route files.

When not to use

  • ❌ Sapper and SvelteKit 1.x are not supported.

Related Packages

Links

License

Apache-2.0 © ObjectStack