We advise to first read this short guide, and then optionally follow up with a framework specific guide.
FilePond works on all modern browsers and devices.
Quick Start
-
Install the package
We can install the
filepondpackage using a package manager, load it from a cdn, or download the files manually.npm install filepond@betapnpm add filepond@betayarn add filepond@betaTo load FilePond from a CDN we add the import map below to the top of our webpage.
<script type="importmap"> { "imports": { "filepond": "https://unpkg.com/filepond@beta/cdn/index.js", "filepond/": "https://unpkg.com/filepond@beta/cdn/" } } </script>To manually install FilePond we start by downloading the FilePond package below.
After we unzip the package we copy the “esm” folder to our project and add the import map below to the top of our webpage.
<script type="importmap"> { "imports": { "filepond": "./path-to-file-pond-esm/index.js", "filepond/": "./path-to-file-pond-esm/" } } </script> -
Add the custom element
Let’s assume we already have a
<input type="file">on our page, to add FilePond we wrap it with our new<file-pond>custom element.<form action="/upload" method="POST"> <label for="my-file">Document</label> <file-pond> <input id="my-file" type="file" name="files" multiple required /> </file-pond> <button type="submit">Upload</button> </form>Nothing happens because we have yet to register the
<file-pond>custom element so the browser knows how to deal with it. -
Register the custom element
We register the
<file-pond>custom element using thedefineFilePondfunction.Let’s import both the function and the English locale, then we call
defineFilePondto register the<file-pond>custom element and pass the importedlocaleto set our default locale.<form action="/upload" method="POST"> <label for="my-file">Document</label> <file-pond> <input id="my-file" type="file" name="files" multiple required /> </file-pond> <button type="submit">Upload</button> </form> <script type="module"> import { defineFilePond } from 'filepond'; import { locale } from 'filepond/locales/en-gb.js'; defineFilePond({ locale, }); </script>We’re done! After refreshing the page FilePond will have replaced the
<input type="file">and theforattribute of our<label>will point to the<file-pond>element.Tap the “Run now” button above to open this example as a demo demo.
Importing the package
Because most web projects these days use a framework or a bundler like Vite the code examples in the documentation import FilePond like a node module.
import { defineFilePond } from 'filepond';
To import FilePond exports without a bundler we have to either use a relative path './filepond/esm/index.js', or we have to set up an import map to import the package.
-import { defineFilePond } from 'filepond';
+import { defineFilePond } from './filepond/esm/index.js';
The import map below redirects the 'filepond' module name to ./filepond/esm/index.js and redirects module paths starting with 'filepond/' to ./filepond/esm/.
<script type="importmap">
{
"imports": {
"filepond": "./filepond/esm/index.js",
"filepond/": "./filepond/esm/"
}
}
</script>
Content Security Policy
If a Content Security Policy (CSP) is present on your website or app we most likely have to update it.
The directives below cover all FilePonds configurations. See below explanation if you want to pick and choose based on your FilePond configuration. Please note that the worker-src directive is optional.
img-src 'self' blob: data:;
media-src 'self' blob:;
worker-src 'self' blob:;
-
To have the
FilePondEntryListElementcorrectly render progress indicators on Safari we need to add thedata:scheme to theimg-srcdirective. -
When using the
MediaResolutionValidatororappendEntryImageViewtemplate we need to add theblob:scheme to theimg-srcdirective so we can read image sizes. -
When using the
MediaResolutionValidatororappendEntryVideoViewwe have to add theblob:scheme to themedia-srcdirective so we can read video size information and show video previews. -
We can choose to add the
blob:scheme to theworker-srcdirective. When its set FilePond can dynamically create threads for processes like creating image previews, asynchronously loading data, and manipulating images. Alternatively we can set theworkersURLproperty when callingdefineFilePondto pass the URL to the worker directy.defineFilePond({ // the `workers` subfolder of the filepond package contains the web worker files. workersURL: 'https://my-site.com/filepond/workers', });
Next steps
- Learn about FilePond custom element core concepts.
- Read how to use FilePond with a JavaScript framework.
- Adjust the FilePond styles to fit your project.
- Customize the FilePond templates for full control over what is rendered.
- Set up asynchronous file uploads, not strictly necessary but often needed.