Electron Integration #1298
-
Thank you, wxt really helps greatly with developing crossbrowser apps - I was wondering if you could also provide some details on how to best extend wxt to also be able to deply as an electron app? (monorepo maybe) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You'll need a monorepo and you'll need to create abstractions that your UI and background logic can depend on. For example, to store settings, you'll probably want to create a storage interface and pass in two different implementations when creating your UI/background logic from each app: // packages/shared/app-storage.ts
export interface AppStorage {
getValue<T>(key: string): Promise<T>;
setValue<T>(key: string, newValue: T): Promise<void>;
} // apps/extension/extension-app-storage.ts
export function createExtensionAppStorage(): AppStorage {
// Implement storage using browser.storage or @wxt-dev/storage or any other extension storage library
} // apps/desktop/desktop-app-storage.ts
export function createDesktopAppStorage(): AppStorage {
// Implement storage using better-sqlite3
} Here's an example monorepo that abstracts things to reuse a UI across a webapp and an extension - basically the same thing as an electron app. |
Beta Was this translation helpful? Give feedback.
You'll need a monorepo and you'll need to create abstractions that your UI and background logic can depend on. For example, to store settings, you'll probably want to create a storage interface and pass in two different implementations when creating your UI/background logic from each app: