### createServer() Source: https://wxt.dev/api/reference/wxt/interfaces/wxtbuilder Start a dev server at the provided port. ```APIDOC ## Method: createServer() ### Description Start a dev server at the provided port. ### Parameters #### Path Parameters * **info** (ServerInfo) - Required - Information about the server to create. ### Response #### Success Response * **Promise** - The created WXT builder server instance. ``` -------------------------------- ### Create and Start WXT Dev Server Source: https://wxt.dev/api/reference/wxt/functions/createserver Use this snippet to create a new WXT development server instance and start it. An optional inline configuration object can be provided to customize the server's behavior. ```typescript const server = await wxt.createServer({ // Enter config... }); await server.start(); ``` -------------------------------- ### server:started Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the development server has started. ```APIDOC ## server:started ### Description Called when the dev server is started. ### Parameters - **wxt** (Wxt) - The configured WXT object. - **server** (WxtDevServer) - The object WXT uses to control the dev server. Same as `wxt.server`. ### Source packages/wxt/src/types.ts:1433 ``` -------------------------------- ### server:started Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the dev server has started. ```APIDOC ## server:started Hook ### Description Called when the dev server has started. ### Signature `server:started: (wxt, url) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. - **url** (`string`) - The URL the dev server is listening on. ### Source `packages/wxt/src/types.ts:1289` ``` -------------------------------- ### Example outBaseDir Source: https://wxt.dev/api/reference/wxt/interfaces/resolvedconfig Specifies the absolute path to the project's .output directory. ```typescript '/path/to/project/.output'; ``` -------------------------------- ### zip:start Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called before the zip process starts. ```APIDOC ## zip:start ### Description Called before the zip process starts. ### Parameters - **wxt** (Wxt) - The configured WXT object. ### Source packages/wxt/src/types.ts:1383 ``` -------------------------------- ### Start the Development Server Source: https://wxt.dev/api/reference/wxt/interfaces/wxtdevserver Initiates the WXT development server. This method is asynchronous and returns a Promise. ```typescript start(): Promise ``` -------------------------------- ### ready Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called once WXT is ready to start the dev server or build. ```APIDOC ## ready Hook ### Description Called once WXT is ready to start the dev server or build. ### Signature `ready: (wxt) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. ### Source `packages/wxt/src/types.ts:1285` ``` -------------------------------- ### Example plugins configuration Source: https://wxt.dev/api/reference/wxt/interfaces/resolvedconfig An array of strings to import plugins. These paths should be resolvable by Vite and export a default defineWxtPlugin function. ```typescript ['@wxt-dev/module-vue/plugin', 'wxt-module-google-analytics/plugin']; ``` -------------------------------- ### zip:extension:start Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the extension zip file creation starts. ```APIDOC ## zip:extension:start Hook ### Description Called when the extension zip file creation starts. ### Signature `zip:extension:start: (wxt) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. ### Source `packages/wxt/src/types.ts:1421` ``` -------------------------------- ### initialize() Source: https://wxt.dev/api/reference/wxt/functions/initialize.html Initializes a new WXT project. This function takes an options object to configure the project setup. ```APIDOC ## Function: initialize() ### Description Initializes a new WXT project with specified options. ### Signature `initialize(options: object): Promise` ### Parameters #### options (`object`) - **options.directory** (`string`) - The directory for the new project. - **options.packageManager** (`string`) - The package manager to use (e.g., 'npm', 'yarn', 'pnpm'). - **options.template** (`string`) - The template to use for the new project. ``` -------------------------------- ### zip:extension:start Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called before zipping the extension files. ```APIDOC ## zip:extension:start ### Description Called before zipping the extension files. ### Parameters - **wxt** (Wxt) - The configured WXT object. ### Source packages/wxt/src/types.ts:1389 ``` -------------------------------- ### Example outDir Source: https://wxt.dev/api/reference/wxt/interfaces/resolvedconfig Specifies the absolute path to the target output directory for a specific browser build. ```typescript '/path/to/project/.output/chrome-mv3'; ``` -------------------------------- ### Example wxtDir Path Source: https://wxt.dev/api/reference/wxt/interfaces/resolvedconfig Illustrates the expected absolute path format for the .wxt directory in the project root. ```typescript '/path/to/project/.wxt'; ``` -------------------------------- ### defineWebExtConfig() Source: https://wxt.dev/api/reference/wxt/functions/definewebextconfig Configures how web-ext starts the browser during development. It takes a configuration object and returns a WebExtConfig object. ```APIDOC ## Function: defineWebExtConfig() > **defineWebExtConfig**(`config`): [`WebExtConfig`] Configure how [`web-ext`](https://github.com/mozilla/web-ext) starts the browser during development. ### Parameters ▪ **config**: [`WebExtConfig`] ### Source [packages/wxt/src/core/define-web-ext-config.ts:16](https://github.com/wxt-dev/wxt/blob/9a638449d587f48c2821ca32577c5758346c3290/packages/wxt/src/core/define-web-ext-config.ts#L16) ``` -------------------------------- ### server:created Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the development server is created and `wxt.server` is assigned. The server has not started yet. ```APIDOC ## server:created ### Description Called when the dev server is created (and `wxt.server` is assigned). Server has not been started yet. ### Parameters - **wxt** (Wxt) - The configured WXT object. - **server** (WxtDevServer) - The object WXT uses to control the dev server. Same as `wxt.server`. ### Source packages/wxt/src/types.ts:1425 ``` -------------------------------- ### zip:start Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the zip creation process starts. ```APIDOC ## zip:start Hook ### Description Called when the zip creation process starts. ### Signature `zip:start: (wxt) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. ### Source `packages/wxt/src/types.ts:1401` ``` -------------------------------- ### zip:sources:start Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called before zipping the source files (for Firefox). ```APIDOC ## zip:sources:start ### Description Called before zipping the source files (for Firefox). ### Parameters - **wxt** (Wxt) - The configured WXT object. ### Source packages/wxt/src/types.ts:1402 ``` -------------------------------- ### Install WXT Analytics Module Source: https://wxt.dev/analytics.html Install the WXT analytics NPM package. Add the module to your wxt.config.ts. ```bash pnpm i @wxt-dev/analytics ``` ```typescript export default defineConfig({ modules: ['@wxt-dev/analytics/module'], }); ``` -------------------------------- ### installDependencies Source: https://wxt.dev/api/reference/wxt/interfaces/wxtpackagemanager Installs all project dependencies. This function can take options to control the installation process, such as specifying the package manager or performing a dry run. ```APIDOC ## installDependencies ### Description Installs project dependencies. ### Method installDependencies ### Parameters #### Path Parameters - **options?** (Pick & object) - Optional - Options to pass to the API call. ### Response #### Success Response - **OperationResult** - Result of the installation operation. ### Source packages/wxt/src/types.ts:1674 ``` -------------------------------- ### zip:sources:start Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called when the zip sources collection starts. ```APIDOC ## zip:sources:start Hook ### Description Called when the zip sources collection starts. ### Signature `zip:sources:start: (wxt) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. ### Source `packages/wxt/src/types.ts:1405` ``` -------------------------------- ### Example outDirTemplate Configuration Source: https://wxt.dev/api/reference/wxt/interfaces/inlineconfig Customizes the output directory structure using template variables like browser, manifest version, and build mode. ```typescript '{{browser}}-mv{{manifestVersion}}' ``` -------------------------------- ### Alias Configuration Example Source: https://wxt.dev/api/reference/wxt/interfaces/inlineconfig Configure additional paths for the .wxt/tsconfig.json. Use this to add new import aliases pointing to specific files or directories. ```typescript { "testing": "src/utils/testing.ts" } ``` -------------------------------- ### BackgroundDefinition Methods Source: https://wxt.dev/api/reference/wxt/interfaces/backgrounddefinition Defines the main function executed when the background script is started. ```APIDOC ## Interface: BackgroundDefinition ### Methods #### main() > **main**(): `void` Main function executed when the background script is started. Cannot be async. ``` -------------------------------- ### Add a Content Script Entrypoint Source: https://wxt.dev/api/reference/wxt/modules/functions/addentrypoint This example demonstrates how to add a content script entrypoint to your WXT project. It specifies the input path, output directory, and extracts entrypoint options using `wxt.builder.importEntrypoint`. ```typescript export default defineWxtModule(async (wxt, options) => { const entrypointPath = '/path/to/my-entrypoint.ts'; addEntrypoint(wxt, { type: 'content-script', name: 'some-name', inputPath: entrypointPath, outputDir: wxt.config.outDir, options: await wxt.builder.importEntrypoint(entrypointPath), }); }); ``` -------------------------------- ### Restart the Development Server Source: https://wxt.dev/api/reference/wxt/interfaces/wxtdevserver Closes the browser, stops the server, rebuilds the extension, and then starts the server again. This method is asynchronous and returns a Promise. ```typescript restart(): Promise ``` -------------------------------- ### Default Chromium Preferences for Development Source: https://wxt.dev/api/reference/wxt/interfaces/webextconfig Example of default Chromium preferences for enabling development mode and allowing content script sourcemaps. ```typescript // Enable dev mode and allow content script sourcemaps { devtools: { synced_preferences_sync_disabled: { skipContentScripts: false, }, } extensions: { ui: { developer_mode: true, }, } } ``` -------------------------------- ### Create Analytics Instance Without WXT Source: https://wxt.dev/analytics.html Install the NPM package and create a custom analytics instance using createAnalytics. This is for projects not using WXT. ```typescript // utils/analytics.ts import { createAnalytics } from '@wxt-dev/analytics'; export const analytics = createAnalytics({ providers: [ // ... ], }); ``` -------------------------------- ### Prepare Types Hook Example Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks This hook is used to modify the entries that WXT uses to generate type definitions. It can be used to add custom type files or reference external type modules. ```typescript wxt.hooks.hook('prepare:types', (wxt, entries) => { // Add a file, ".wxt/types/example.d.ts", that defines a global // variable called "example" in the TS project. entries.push({ path: 'types/example.d.ts', text: 'declare const a: string;', tsReference: true, }); // use module to add Triple-Slash Directive in .wxt/wxt.d.ts // eg: /// entries.push({ module: '@types/example', }); }); ``` -------------------------------- ### prepare() Source: https://wxt.dev/api/reference/wxt/functions/prepare.html Initializes WXT with the provided inline configuration. This function returns a Promise that resolves when the preparation is complete. ```APIDOC ## Function: prepare() > **prepare**(`config`): `Promise` ### Description Initializes WXT with the provided inline configuration. This function returns a Promise that resolves when the preparation is complete. ### Parameters #### Parameters - **config** (`InlineConfig`) - Required - The inline configuration object for WXT. ``` -------------------------------- ### ready Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called after WXT modules are initialized, when the WXT instance is ready to be used. Note that `wxt.server` is not available yet; use `server:created` for that. ```APIDOC ## ready ### Description Called after WXT modules are initialized, when the WXT instance is ready to be used. `wxt.server` isn't available yet, use `server:created` to get it. ### Parameters - **wxt** (Wxt) - The configured WXT object. ### Source packages/wxt/src/types.ts:1271 ``` -------------------------------- ### build() Source: https://wxt.dev/api/reference/wxt/functions/build.html Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in the root directory, and merges that config with what is passed in. ```APIDOC ## Function: build() > **build**(`config`?): `Promise`<[`BuildOutput`](../interfaces/BuildOutput.md)> Bundles the extension for production. Returns a promise of the build result. Discovers the `wxt.config.ts` file in the root directory, and merges that config with what is passed in. ### Parameters ▪ **config?**: [`InlineConfig`](../interfaces/InlineConfig.md) ### Returns `Promise`<[`BuildOutput`](../interfaces/BuildOutput.md)> ### Example ```ts // Use config from `wxt.config.ts` const res = await build(); // or override config `from wxt.config.ts` const res = await build({ // Override config... }); ``` ``` -------------------------------- ### createServer() Source: https://wxt.dev/api/reference/wxt/functions/createserver Creates a development server instance. This function is asynchronous and returns a Promise that resolves to a WxtDevServer object. It accepts an optional inline configuration object. ```APIDOC ## Function: createServer() > **createServer**(`inlineConfig`?): `Promise`<[`WxtDevServer`](../interfaces/WxtDevServer.md)> Creates a dev server and pre-builds all the files that need to exist before loading the extension. ### Parameters ▪ **inlineConfig?**: [`InlineConfig`](../interfaces/InlineConfig.md) ### Returns ## Example ```ts const server = await wxt.createServer({ // Enter config... }); await server.start(); ``` ``` -------------------------------- ### build:before Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called before the build is started in both dev mode and build mode. Allows for pre-build modifications. ```APIDOC ## build:before Hook ### Description Called before the build is started in both dev mode and build mode. ### Signature `build:before: (wxt) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. ### Source `packages/wxt/src/types.ts:1325` ``` -------------------------------- ### build() Source: https://wxt.dev/api/reference/wxt/interfaces/wxtbuilder Build a single entrypoint group. This is effectively one of the multiple "steps" during the build process. ```APIDOC ## Method: build() ### Description Build a single entrypoint group. This is effectively one of the multiple "steps" during the build process. ### Parameters #### Path Parameters * **group** (EntrypointGroup) - Required - The entrypoint group to build. ### Response #### Success Response * **Promise** - The output of the build step. ``` -------------------------------- ### CopiedPublicFile absoluteSrc Example Source: https://wxt.dev/api/reference/wxt/interfaces/copiedpublicfile Specifies the absolute path of the file to be copied. This is the source location on your local filesystem. ```typescript '/path/to/any/file.css'; ``` -------------------------------- ### Configure WXT Analytics Provider Source: https://wxt.dev/analytics.html Configure an analytics provider in your app.config.ts. This example shows Umami provider configuration. ```typescript // /app.config.ts import { umami } from '@wxt-dev/analytics/providers/umami'; export default defineAppConfig({ analytics: { debug: true, providers: [ // ... ], }, }); ``` -------------------------------- ### Customize Auto-Import Options Source: https://wxt.dev/api/reference/wxt/interfaces/inlineconfig Example of customizing auto-import options by adding a directory to import from. Set to `false` to disable auto-imports. ```typescript export default defineConfig({ imports: { dirs: ['some-directory'], }, }); ``` -------------------------------- ### Build Extension with wxt.build() Source: https://wxt.dev/api/reference/wxt/functions/build.html Use the `build()` function to bundle your extension. You can either rely on the configuration defined in your `wxt.config.ts` file or override specific settings by passing an inline configuration object. ```typescript import { build } from 'wxt'; // Use config from `wxt.config.ts` const res = await build(); // or override config `from wxt.config.ts` const res = await build({ // Override config... }); ``` -------------------------------- ### zip() Source: https://wxt.dev/api/reference/wxt/functions/zip.html Builds and zips the extension for distribution. Accepts an optional configuration object to override default settings and returns a promise with a list of all files included in the ZIP. ```APIDOC ## Function: zip() > **zip**(`config`?): `Promise`<`string`[]> Build and zip the extension for distribution. ### Parameters ▪ **config?**: [`InlineConfig`](../interfaces/InlineConfig.md) Optional config that will override your `/wxt.config.ts`. ### Returns A list of all files included in the ZIP. ### Source [packages/wxt/src/core/zip.ts:22](https://github.com/wxt-dev/wxt/blob/9a638449d587f48c2821ca32577c5758346c3290/packages/wxt/src/core/zip.ts#L22) ``` -------------------------------- ### ensureDependencyInstalled Source: https://wxt.dev/api/reference/wxt/interfaces/wxtpackagemanager Ensures that a specific dependency is installed in the project. It accepts the dependency name and optional options like workspace, cwd, or dev. ```APIDOC ## ensureDependencyInstalled ### Description Ensures dependency is installed. ### Method ensureDependencyInstalled ### Parameters #### Path Parameters - **name** (string) - Required - Name of the dependency. - **options?** (Pick) - Optional - Options to pass to the API call. ### Response #### Success Response - **true | undefined** - Indicates if the dependency was installed or already present. ### Source packages/wxt/src/types.ts:1673 ``` -------------------------------- ### typesDir Source: https://wxt.dev/api/reference/wxt/interfaces/resolvedconfig Represents the absolute path to the .wxt directory in the project root. ```APIDOC ## typesDir ### Description Represents the absolute path to the `.wxt` directory in the project root. ### Type `string` ``` -------------------------------- ### WxtDevServer Methods Source: https://wxt.dev/api/reference/wxt/interfaces/wxtdevserver This section details the core methods available on the WxtDevServer interface for controlling the development server and its associated processes. ```APIDOC ## start() ### Description Starts the WXT development server. ### Method start ### Returns `Promise` ### Source packages/wxt/src/types.ts:525 ``` ```APIDOC ## stop() ### Description Stops the WXT development server. ### Method stop ### Returns `Promise` ### Source packages/wxt/src/types.ts:527 ``` ```APIDOC ## restart() ### Description Closes the browser, stops the server, rebuilds the entire extension, and starts the server again. ### Method restart ### Returns `Promise` ### Source packages/wxt/src/types.ts:532 ``` ```APIDOC ## transformHtml(url, html, originalUrl?) ### Description Transforms the HTML for development mode. ### Method transformHtml ### Parameters #### Path Parameters - **url** (string) - Required - The URL to transform. - **html** (string) - Required - The HTML content to transform. - **originalUrl** (string) - Optional - The original URL of the HTML. ### Returns `Promise` ### Overrides Omit.transformHtml ### Source packages/wxt/src/types.ts:534 ``` ```APIDOC ## reloadPage(path) ### Description Tells an extension page to reload. The path provided should be the bundle path, not the input path. ### Method reloadPage ### Parameters #### Path Parameters - **path** (string) - Required - The bundle path of the page to reload (e.g., 'options.html'). ### Example ts ```ts server.reloadPage('popup.html'); server.reloadPage('sandbox.html'); ``` ### Source packages/wxt/src/types.ts:553 ``` ```APIDOC ## reloadContentScript(payload) ### Description Tells the extension to restart a content script. ### Method reloadContentScript ### Parameters #### Path Parameters - **payload** (ReloadContentScriptPayload) - Required - Information about the content script to reload. ### Source packages/wxt/src/types.ts:559 ``` ```APIDOC ## reloadExtension() ### Description Tells the extension to reload by running `browser.runtime.reload`. ### Method reloadExtension ### Source packages/wxt/src/types.ts:540 ``` ```APIDOC ## restartBrowser() ### Description Grabs the latest runner config and restarts the browser. ### Method restartBrowser ### Source packages/wxt/src/types.ts:561 ``` -------------------------------- ### importEntrypoints() Source: https://wxt.dev/api/reference/wxt/interfaces/wxtbuilder Import a list of JS entrypoint files, returning their options. ```APIDOC ## Method: importEntrypoints() ### Description Import a list of JS entrypoint files, returning their options. ### Parameters #### Path Parameters * **paths** (string[]) - Required - A list of paths to the JS entrypoint files. ### Response #### Success Response * **Promise[]>** - An object where keys are entrypoint names and values are their options. ``` -------------------------------- ### Example suppressWarnings Configuration Source: https://wxt.dev/api/reference/wxt/interfaces/inlineconfig Configures WXT to suppress specific build warnings, such as those related to Firefox data collection or missing extension IDs. ```typescript export default defineConfig({ suppressWarnings: { firefoxDataCollection: true, }, }); ``` -------------------------------- ### include Source: https://wxt.dev/api/reference/wxt/interfaces/mainworldcontentscriptdefinition Specifies a list of target browsers for which this entrypoint should be included. If not provided, it defaults to being included in all builds. This option cannot be used with `exclude`. ```APIDOC ## include ### Description List of target browsers to include this entrypoint in. Defaults to being included in all builds. Cannot be used with `exclude`. You must choose one of the two options. ### Type `string`[] ### Default ``` undefined ``` ``` -------------------------------- ### prepare:types Hook Source: https://wxt.dev/api/reference/wxt/interfaces/wxthooks Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing addition of custom references and declarations. ```APIDOC ## prepare:types Hook ### Description Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing addition of custom references and declarations in wxt.d.ts, or directly modifying the options in `tsconfig.json`. ### Signature `prepare:types: (wxt, entries) => HookResult` ### Parameters #### Path Parameters - **wxt** (`Wxt`) - The configured WXT object. - **entries** (`any[]`) - Placeholder for entries, actual type not specified in source. ### Source `packages/wxt/src/types.ts:1309` ``` -------------------------------- ### MainWorldContentScriptEntryPointOptions Source: https://wxt.dev/api/reference/wxt/interfaces/mainworldcontentscriptentrypointoptions Configuration options for content scripts running in the main world. ```APIDOC ## MainWorldContentScriptEntryPointOptions ### Description Options for configuring content scripts that run in the main world. ### Properties #### `registration` - **registration** (PerBrowserOption<"runtime" | "manifest">) - Optional - Specify how the content script is registered. Can be "manifest" (default) to add to the manifest's `content_scripts` entry, or "runtime" to use the scripting API for dynamic registration. #### `runAt` - **runAt** (PerBrowserOption) - Optional - Specifies when the content script should run. Defaults to 'documentIdle'. See https://developer.chrome.com/docs/extensions/mv3/content_scripts/. #### `world` - **world** ("MAIN") - Required - Specifies that the content script runs in the "MAIN" world. See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world. ``` -------------------------------- ### MainWorldContentScriptEntrypointOptions Source: https://wxt.dev/api/reference/wxt/interfaces/mainworldcontentscriptentrypointoptions Options for configuring content scripts that run in the main world. ```APIDOC ## MainWorldContentScriptEntrypointOptions ### Description Options for configuring content scripts that run in the main world. ### Properties #### globalName - **globalName** (string | boolean | entrypoint => string) - Optional - The variable name for the IIFE in the output bundle. This option is relevant for scripts inserted into the page context where the default IIFE variable name may conflict with an existing variable on the target page. This applies to content scripts with world=MAIN, and others, such as unlisted scripts, that could be dynamically injected into the page with a `