> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Function Library Extension Files and Code

## Article: Function Library Extension Files and Code

## Article Link: https://dev.wix.com/docs/site-extensions/function-libraries/function-library-extension-files-and-code.md

## Article Content:

# Function Library Extension Files and Code

A [function library](https://dev.wix.com/docs/overview/extensions-framework/site-extensions/function-libraries.md) is a manifest and an implementation file that describe the same set of functions:

- A `<name>.extension.ts` file that holds the [manifest](#manifest), which declares each function's name, parameters, and return type.
- A `<name>.ts` file that holds the [implementation](#implementation), the code that implements the functions.

Function libraries are currently only available for Studio Two sites.

## Manifest

The `<name>.extension.ts` file holds the manifest.

The manifest includes:

- `functions`: Functions the library exposes.
- `resources`: Where the implementation code lives.

For example, a generated price-formatting library declares 1 function and points to its implementation file:

```ts
import { extensions } from '@wix/custom-extensions';

export default extensions.functionLibrary({
  id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
  name: 'My Function Library',
  type: 'companionApp.myFunctionLibrary',
  functions: {
    formatPrice: {
      displayName: 'Format price',
      description: 'Formats an amount as a price string',
      parameters: [
        {
          dataType: 'number',
          displayName: 'Amount',
        },
        {
          dataType: 'text',
          displayName: 'Currency symbol',
          optional: true,
        },
      ],
      returns: {
        dataType: 'text',
        displayName: 'Formatted price',
      },
    },
  },
  resources: {
    client: {
      url: './extensions/site/function-libraries/my-function-library/my-function-library.ts',
    },
  },
});
```

For the full manifest reference, see [About the Function Library Manifest](https://dev.wix.com/docs/site-extensions/function-libraries/about-the-function-library-manifest.md).

## Implementation

The `<name>.ts` file holds the implementation.

It exports one function per entry in the manifest, matching it by name:

```ts
export function formatPrice(amount: number, currencySymbol = '$'): string {
  return `${currencySymbol}${amount.toFixed(2)}`;
}
```

## See also

- [About Function Libraries](https://dev.wix.com/docs/site-extensions/function-libraries/about-function-libraries.md)
- [Function Libraries](https://dev.wix.com/docs/overview/extensions-framework/site-extensions/function-libraries.md)
- [Add a Function Library Extension in Studio Two](https://dev.wix.com/docs/studio-two/code-your-site/code-model/function-libraries/add-a-function-library-extension-in-studio-two.md)
- [About the Function Library Manifest](https://dev.wix.com/docs/site-extensions/function-libraries/about-the-function-library-manifest.md)