---
title: "Virtual Files API"
---

# Virtual Files API

Limesdocs manipulates virtual files, meaning that these files do not necessarily exist on a filesystem. 
This is a great abstraction which allows Limedocs to source, transform, and output practically anything, everywhere. 
Once created, virtual files pass through the whole pipeline and can be modified without touching the filesystem.


## Usage

The `VFile` class that Limedocs exposes extends the [vfile class from unifiedjs](https://github.com/vfile/vfile). Make sure to check their implementation to check all properties and methods originally supported.

### Importing

```js
import { vfile } from "@limedocs/core"
// vfile is a function that you can use to create new Virtual files

const myFile = vfile({
  path: "/my/path/to/file.txt", 
  contents: "Hello world"
})
```

### API

#### `vfile({ path: string, contents: Buffer | string}): VFile`

Helper method to create a new virtual file.

#### VFile properties

| Name | Description
| --- | --- |
| `contentType` | File content-type. Will be automatically computed based on `path` extension. If Limedocs cannot determine it, it will be set to `application/octet-stream`. Can also be passed directly in contructor options. |
| `context` | An object describing the file context. |
| `datastore` | The datastore instance attached to the file. |
| `path` | File path |
| `contents` | File contents. |

See also original [properties and methods of unifiedjs's vfile format](https://github.com/vfile/vfile).

