{"id":14962544,"url":"https://github.com/kumpmati/sveltekit-superactions","last_synced_at":"2025-10-24T22:32:36.942Z","repository":{"id":248372713,"uuid":"827853352","full_name":"kumpmati/sveltekit-superactions","owner":"kumpmati","description":"Call your server code from the client like normal functions.","archived":false,"fork":false,"pushed_at":"2024-07-21T18:05:06.000Z","size":255,"stargazers_count":12,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-29T10:52:02.296Z","etag":null,"topics":["api","server-actions","svelte","sveltejs","sveltekit"],"latest_commit_sha":null,"homepage":"https://superactions.matsku.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kumpmati.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-12T14:16:38.000Z","updated_at":"2024-09-27T18:21:00.000Z","dependencies_parsed_at":"2024-07-20T08:50:37.006Z","dependency_job_id":null,"html_url":"https://github.com/kumpmati/sveltekit-superactions","commit_stats":null,"previous_names":["kumpmati/sveltekit-superactions"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kumpmati%2Fsveltekit-superactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kumpmati%2Fsveltekit-superactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kumpmati%2Fsveltekit-superactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kumpmati%2Fsveltekit-superactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kumpmati","download_url":"https://codeload.github.com/kumpmati/sveltekit-superactions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867519,"owners_count":16555889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","server-actions","svelte","sveltejs","sveltekit"],"created_at":"2024-09-24T13:29:59.765Z","updated_at":"2025-10-24T22:32:31.380Z","avatar_url":"https://github.com/kumpmati.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/kumpmati/superactions-docs/main/public/logo.webp\" width=\"64px\" align=\"center\" alt=\"Superactions logo\" /\u003e \n\u003ch1\u003eSvelteKit Superactions\u003c/h1\u003e\n\n[![Test](https://github.com/kumpmati/sveltekit-superactions/actions/workflows/test.yml/badge.svg)](https://github.com/kumpmati/sveltekit-superactions/actions/workflows/test.yml)\n\nCall your server code from the client like normal functions.\n\n**🚧 This library is in an early state, and breaking changes will likely happen before the API is stabilised for a v1.0 release! 🚧**\n\n[Documentation](https://superactions.matsku.dev)\n\n## Why?\n\nWhile SvelteKit's data fetching patterns are great, but the ease-of-use of React Server Actions doesn't seem to have an equivalent in SvelteKit. The ability to just 'call a function' in the client-side, have it perform logic on the server and return the result to the client is sometimes very useful.\n\nSvelteKit's [form actions](https://kit.svelte.dev/docs/form-actions) are a great fit for many cases, but they can be clunky when you want to call an endpoint without a form element, or when you need to send data that is too complex to be represented in FormData.\n\nThis library aims to provide additional tools alongside SvelteKit's API routes:\n\n## Features\n\n- [x] Type satefy between server and client\n- [x] Automatic JSON conversion (request/response)\n- [x] Schema validation\n  - [x] `zod` helper function\n  - [x] `joi` helper function\n\n## Installation\n\nInstall Superactions with your favourite package manager:\n\n```bash\n# npm, yarn, pnpm, bun, etc\nnpm i sveltekit-superactions\n```\n\n## Usage\n\nA minimal setup requires the following.\n\nIn a `+server.ts` file, define the actions that you want to use:\n\n```ts\n// src/routes/api/+server.ts\nimport { endpoint } from 'sveltekit-superactions';\nimport { db } from '$lib/server/db';\nimport { deleteTodo, findTodo, type TodoUpdate } from '$lib/server/handlers';\n\n// Always attach the endpoint as a POST handler\nexport const POST = endpoint({\n\t// e is the RequestEvent provided by SvelteKit,\n\t// and the second argument is the request body decoded as JSON.\n\teditTodo: async (e, body: TodoUpdate) =\u003e {\n\t\t// The returned value is automatically serialized as JSON.\n\t\t// The client-side function gets its return type directly from the return type of its server action\n\t\treturn await db.update(body.id, body);\n\t},\n\n\t// You can also just import handlers from other files and group them here.\n\tdeleteTodo,\n\n\t// Or give them custom names\n\tmy_handler: findTodo\n});\n\n// export the type of the endpoint, so that we get types in the client\nexport type API = typeof POST;\n```\n\nAnd in any Svelte component import the `superActions` function and the exported types to instantiate the client.\n\n```svelte\n\u003c!-- src/routes/+page.svelte --\u003e\n\u003cscript lang=\"ts\"\u003e\n\timport { superActions } from 'sveltekit-superactions';\n\timport type { API } from './api/+server.js'; // exported API type\n\n\t// give the client the path and API types to instantiate it.\n\tconst api = superActions\u003cAPI\u003e('/api');\n\u003c/script\u003e\n\n{#await api.getTodos()}\n\t\u003cp\u003eLoading TODOs...\u003c/p\u003e\n{:then todos}\n\t\u003cul\u003e\n\t\t{#each todos as todo}\n\t\t\t\u003cli\u003e\n\t\t\t\t{todo.text}\n\t\t\t\t\u003cinput type=\"checkbox\" checked={todo.checked} /\u003e\n\t\t\t\u003c/li\u003e\n\t\t{/each}\n\t\u003c/ul\u003e\n{/await}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumpmati%2Fsveltekit-superactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkumpmati%2Fsveltekit-superactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumpmati%2Fsveltekit-superactions/lists"}