The Lekko Vite plugin allows you to set up build-time code transformation to enable lekkos in your Vite projects.
With this plugin, you can write your lekkos as pure functions, which are transformed at build time to code that connects to Lekko's services to serve the latest dynamic values with static fallback built in.
- Vite >= 4
- TypeScript
Add this plugin to your vite.config.js
config. The lekko()
call should come last in the list of plugins.
Example for a React project:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import lekko from "@lekko/vite-plugin";
export default defineConfig({
plugins: [react(), lekko()],
...
})
To connect your project to Lekko's services when building (e.g. when deploying), pass the VITE_LEKKO_API_KEY
environment variable.
You can generate API keys for your team on the Lekko web UI by clicking on your team in the top navigation bar -> Admin tab -> API keys.
Enables verbose logging for debugging purposes. Defaults to false.
lekko({ verbose: true });