From b8b1ee04ab349c7f7ac823240274f8f586926af0 Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Tue, 5 Aug 2025 10:40:31 +1000 Subject: [PATCH 1/4] add better error handling --- src/lib/components/providers.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/components/providers.svelte b/src/lib/components/providers.svelte index 8d555cba..015747ba 100644 --- a/src/lib/components/providers.svelte +++ b/src/lib/components/providers.svelte @@ -8,7 +8,9 @@ let { children } = $props(); // Setup Convex - setupConvex(PUBLIC_CONVEX_URL); + if (PUBLIC_CONVEX_URL) { + setupConvex(PUBLIC_CONVEX_URL); + } From db44468876134ab496f1115eff3ffb6c3cb01fde Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Tue, 5 Aug 2025 11:05:53 +1000 Subject: [PATCH 2/4] update vite config --- vite.config.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 2f222dba..c5cc9716 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,15 @@ import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; +import { defineConfig, loadEnv } from 'vite'; import tailwindcss from '@tailwindcss/vite'; -export default defineConfig({ - plugins: [tailwindcss(), sveltekit()] +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ''); + + return { + plugins: [tailwindcss(), sveltekit()], + define: { + 'process.env.PUBLIC_CONVEX_URL': JSON.stringify(env.PUBLIC_CONVEX_URL), + 'process.env.PUBLIC_CLERK_PUBLISHABLE_KEY': JSON.stringify(env.PUBLIC_CLERK_PUBLISHABLE_KEY) + } + }; }); From dedf2ba58a4c7cd4d24d0d84dba41c3263f53029 Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Tue, 5 Aug 2025 11:06:53 +1000 Subject: [PATCH 3/4] add better error handling --- src/lib/components/providers.svelte | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/components/providers.svelte b/src/lib/components/providers.svelte index 015747ba..2122356a 100644 --- a/src/lib/components/providers.svelte +++ b/src/lib/components/providers.svelte @@ -2,18 +2,15 @@ import { ClerkProvider, GoogleOneTap } from 'svelte-clerk/client'; import { ModeWatcher } from 'mode-watcher'; import { setupConvex } from 'convex-svelte'; - import { PUBLIC_CLERK_PUBLISHABLE_KEY, PUBLIC_CONVEX_URL } from '$env/static/public'; // Props let { children } = $props(); // Setup Convex - if (PUBLIC_CONVEX_URL) { - setupConvex(PUBLIC_CONVEX_URL); - } + setupConvex(process.env.PUBLIC_CONVEX_URL || ''); - + {@render children()} From da68c73553c4daa0e9be468a967c47c1e4643c86 Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Tue, 5 Aug 2025 11:08:11 +1000 Subject: [PATCH 4/4] updat example envs --- .env.example | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 57b08d7e..bf495ee6 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,3 @@ -# Environment Variables Template -# Copy this file to .env and fill in your values - -# Clerk Authentication -PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_example_key_here - -# Convex Database -PUBLIC_CONVEX_URL=https://example.convex.cloud +PUBLIC_CLERK_PUBLISHABLE_KEY=pk_something +CONVEX_DEPLOYMENT=dev:something +PUBLIC_CONVEX_URL=https://something.convex.cloud