vite.config.ts
Full reference for the omniSvelte plugin configuration in vite.config.ts.
Configuration
All OmniSvelte options are passed to the omniSvelte() plugin in vite.config.ts. This page covers every available option. Standard SvelteKit config options can still be passed under the kit property.
Top-level shape
omniSvelte({
kit?: KitConfig; // standard SvelteKit options
database?: DatabaseConfig;
schema?: SchemaConfig;
auth?: AuthConfig;
logging?: { enabled: boolean };
cors?: { enabled: boolean };
analytics?: { enabled: boolean };
errorReporting?: { enabled: boolean };
})database
omniSvelte({
database: {
enabled: true,
connection: { url: process.env.DATABASE_URL }
}
})schema
Controls how OmniSvelte discovers and generates code from your .schema.ts files.
omniSvelte({
schema: {
input: { patterns: ['src/**/*.schema.ts'] },
output: {
drizzle: { path: 'src/lib/db/server/schema.ts', format: 'single-file' },
zod: { path: 'src/lib/db/validation', format: 'per-schema' },
model: { path: 'src/lib/db/models', format: 'per-schema' }
},
dev: { watch: true, generateOnStart: true }
}
})auth
Configures Better-Auth.
omniSvelte({
auth: {
enabled: true,
secret: process.env.BETTER_AUTH_SECRET,
baseURL: process.env.BETTER_AUTH_URL,
emailAndPassword: { enabled: true },
plugins: {
magicLink: true,
twoFactor: true
}
}
})Standalone Plugin (omni)
By default, omniSvelte() wraps and invokes the official @sveltejs/kit/vite plugin for you. If you need full control over the SvelteKit plugin (e.g., using a custom fork or strictly controlling plugin order), you can use the omni() export instead.
This returns an array of Omni plugins without injecting SvelteKit.
// vite.config.ts
import { defineConfig } from 'vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { omni } from 'omni-svelte/vite';
export default defineConfig({
plugins: [
sveltekit({
experimental: { remoteFunctions: true },
compilerOptions: { experimental: { async: true } }
}), // fully under your control
...omni({
database: { enabled: true },
schema: { /* ... */ }
})
]
});Note: When using
omni()directly, you are responsible for enablingkit.experimental.remoteFunctionsandcompilerOptions.experimental.asyncdirectly via the options passed to thesveltekit()Vite plugin if you want remote functions to work properly.
Full example
// vite.config.ts
import { defineConfig } from 'vite';
import { omniSvelte } from 'omni-svelte/vite';
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [
omniSvelte({
preprocess: vitePreprocess(),
kit: { adapter: adapter() },
database: {
enabled: true,
connection: { url: process.env.DATABASE_URL }
},
schema: {
input: { patterns: ['src/**/*.schema.ts'] },
output: {
drizzle: { path: 'src/lib/db/server/schema.ts', format: 'single-file' },
zod: { path: 'src/lib/db/validation', format: 'per-schema' },
model: { path: 'src/lib/db/models', format: 'per-schema' }
}
},
auth: {
enabled: true,
secret: process.env.BETTER_AUTH_SECRET,
emailAndPassword: { enabled: true }
}
})
]
});