Fatima Logofatima
Frameworks

Sveltekit

"web development for the rest of us"

What should I know?

Here's a list of things SvelveKit does natively:

  • Environments type safety (no need for Fatima's client).
  • Private and public secrets (again no need for Fatima's client)
  • Secret leaking (no need for Fatima's ESLint rule).

How to integrate with Fatima

Things are pretty straight forward, but as mentioned, you won't need Fatima's generated client neither the provided ESLint rule.

As we won't be generating the client, Fatima provides underlying type API so that you can generate your validation constraints.

Dev script

package.json
{
  "scripts": {
    "dev": "fatima dev --lite -- vite dev"
  }
}

The --lite flag will disable the client generation.

Config file

import { env } from "$env/dynamic/private";
import { EnvRecord } from "@fatimajs/tools/env";
import { validate, config, adapters } from "fatima";
import { z, ZodType } from "zod";
 
type DynamicPrivateEnvObject = typeof env;
 
type Constraint = EnvRecord<DynamicPrivateEnvObject, ZodType>;
 
export const constraint: Constraint = {
  NODE_ENV: z.enum(["development", "staging", "production"]),
  PORT: z.number().int().positive(),
  API_URL: z.string().url(),
};
 
type Environment = 'development' | 'staging' | 'production'
 
export default config<Environment>({
  environment: (processEnv) => processEnv.NODE_ENV ?? "development"
  validate: validate.zod(constraint),
  load: {
    development: [adapters.local.load(".env")]
  }
});

On this page