zsarver
zsarver
CDCloudflare Developers
Created by Magick on 7/2/2024 in #pages-help
Pages, Sveltekit and Environment variables
I was struggling on this yesterday too 😅 . You'll need to add the Platform interface like below, but noting I was trying to use D1. After this i was able to use platform.env.DB
interface Platform {
env: {
DB: D1Database;
};
context: {
waitUntil(promise: Promise<any>): void;
};
caches: CacheStorage & { default: Cache }
}
interface Platform {
env: {
DB: D1Database;
};
context: {
waitUntil(promise: Promise<any>): void;
};
caches: CacheStorage & { default: Cache }
}
For regular env variables i to still add them to wrangler.toml and .env to get it to work with the $public/$private like you were mentioning
7 replies