> For the complete documentation index, see [llms.txt](https://docs.create-scandipwa-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.create-scandipwa-app.com/extensions/virtual-modules.md).

# Module preference

ScandiPWA introduces concept of module preference. **This is a feature of** [**ScandiPWA extensions**](/extensions/extensions.md).&#x20;

{% hint style="info" %}
**To preference a module** - to take-over another NPM or virtual module. To take-over means to completely replace an implementation, the original module will not be available.
{% endhint %}

To preference a module, set the `scandipwa.preference`  field of `package.json` equal to the desired module name.

{% hint style="danger" %}

### Watch out!

This is very dangerous to preference a real NPM module, like in example `react` or `redux`. While you can do this, this feature is meant for [virtual module preference](/extensions/extensions.md#virtual-module-preference).
{% endhint %}

### &#x20;Virtual module preference

{% hint style="danger" %}

### Watch out!

This is a subject to change. We plan on providing a more robust way to depend on virtual modules. **They should be coupled with typescript interfaces**. Currently, virtual-modules only work on the level of module resolution, they do not provide any interface for the implementation.&#x20;
{% endhint %}

Create ScandiPWA App introduces the concept of "virtual module".

{% hint style="info" %}
**Virtual module** - a non-existing module, referenced in the code. It provides an abstraction layer, which allows to swap the implementation.
{% endhint %}

Virtual modules are useful for UI elements, where different libraries could be used as an implementation, or for an API endpoints, where the application is relying on data format, not the source of the data.

To create a virtual module, define the reference to a non existing module, and [implement a preference](/extensions/extensions.md#extension-module-preference) in your extension to it. To ensure that it does not exist, use `@virtual-module/<name>` name for it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.create-scandipwa-app.com/extensions/virtual-modules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
