---
url: /api/reference/wxt/modules/functions/addAlias.md
---

[API](../../../packages.md) / [wxt/modules](../index.md) / addAlias

# Function: addAlias()

> **addAlias**(`wxt`, `alias`, `path`): `void`

Source: [packages/wxt/src/modules/index.ts:225](https://github.com/wxt-dev/wxt/blob/a34b49d6b92f500ed9cb5ad4934510e834f49704/packages/wxt/src/modules/index.ts#L225)

Adds an import alias to the project's TSConfig paths and bundler. Path can be
absolute or relative to the project's root directory.

Usually, this is used to provide access to some code generated by your
module. In the example below, a `i18n` plugin generates a variable that it
wants to provide access to, so it creates the file and adds an import alias
to it.

## Parameters

### wxt

[`Wxt`](../../interfaces/Wxt.md)

### alias

`string`

### path

`string`

## Returns

`void`

## Example

```ts
import path from 'node:path';

  export default defineWxtModule((wxt) => {
    const i18nPath = path.resolve(wxt.config.wxtDir, 'i18n.ts');

    // Generate the file
    wxt.hooks.hook('prepare:types', (_, entries) => {
      entries.push({
        path: i18nPath,
        text: `export const i18n = ...`,
      });
    });

    // Add alias
    addAlias(wxt, '#i18n', i18nPath);
  });
```

***

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
