It's easy to get started using Flatfile. For people using Javascript or jQuery, you have two distinct paths you can take. You can use our NPM package or a CDN to load Flatfile.
In this guide, we will use the bare minimum to get up and running with Flatfile, but in order to get the most out of Flatfile's Portal, continue to the next few pages in order to get data validation implemented.
Whether you're using the npm package and importing it into your code or working with static html files and the CDN, the very basics of how to work with Flatfile remain the same. The differences between the two implementations can be seen below in separate sections, but in this section, we will talk about each required piece of Flatfile.
If you're working with with static index.html files, you'll need to run some sort of a simple server in order to see Flatfile work locally. One of the simplest servers you can run is with a python server. If you have python installed (which comes included with most operating systems), then you can open a terminal or command line program, navigate to the directory where the index.html file is and run python -m SimpleHTTPServer 8000
. Once the server is running, you'll be able to open a browser and go to localhost:8000
and see the served version of the webpage.
The first thing you will do is either import the Flatfile package or use a script tag to reference the CDN. Once that is complete, you'll need to start a new reference to the
FlatfileImporter
type
fields
One other required aspect of using Flatfile is referencing the user or customer with the
setCustomer
setCustomer
userId
The final piece to working with Flatfile is to start the import. When doing this, you will use the
requestDataFromUser
.then()
If you're using a modern framework like Angular or Vue (for React users, check out our React documentation and for Angular users, check out our Angular documentation) or you have a nice build system like Webpack in place. You can install and use Flatfile as an external dependency via NPM. Also note that you'll need to use your license key. In the code snippet where it says,
"Replace me with your license key!"
Below is the full example. Do note that we are referencing an element with the id of
flatfile-button
The latest version of the package is available via CDN. You can just a script tag into your website and start using Flatfile. Add the following code before the ending
</body>
In the example below, you'll get a basic version of the Flatfile importer. Reminder, you'll need to use your license key. In the code snippet where it says,
"Replace me with your license key!"