SvelteKit TypeSafe API screenshot

SvelteKit TypeSafe API

Author Avatar Theme by Guibi1
Updated: 18 Jan 2024
10 Stars

Adding type safety to SvelteKit's server endpoints.

Categories

Overview:

The SvelteKit TypeSafe API Fetch is a package that aims to make fetching and validating server endpoints easier in SvelteKit. It provides type-safe fetch-like functions and utilizes the powerful zod library for parsing incoming data. The package is easy to install and offers a plug and play, opt-in structure.

Features:

  • Type safe fetch-like functions: Provides type-safe fetch-like functions that improve the coding experience.
  • Usage of the zod library: Utilizes the zod library for parsing and validating incoming data.
  • Plug and play and opt-in structure: Offers a plug and play, opt-in structure that allows for easy integration into existing projects.

Installation:

To install the SvelteKit TypeSafe API Fetch package, follow these steps:

  1. Install the package using your favorite NodeJS package manager.
  2. Add the vite plugin to your project.
  3. Create a zod object to validate the request body of your endpoint and pass it to the validate function.

Summary:

The SvelteKit TypeSafe API Fetch package simplifies the process of fetching and validating server endpoints in SvelteKit. It provides type-safe fetch-like functions and utilizes the zod library for parsing and validating incoming data. The package is easy to install and offers a plug and play, opt-in structure. Although it is still in beta, feedback, bug reports, and contributions are welcome.