Before you begin
Get your keys
To complete this tutorial, you'll need to retrieve your Publishable key from yourdevelopment
environment.
Note: The Publishable Key is safe to be used in client-side applications as it
has limited access to the Flatfile API.
Prepare your project
Install packages
Make a new directory.init
command.
Create your file structure
Setup your app to look something like this:public
and src.
The public
directory contains the index.html
file, which is the entry point of the application’s front-end, and the “style.css” file for styling the iframe.
The src
directory contains the main components and logic of the application, including the App.tsx
file, which initializes Flatfile and passes in available options.
Build your importer
1. Add a Flatfile button
Add a button to your application to open Flatfile in a modal. Pass in yourpublishableKey
and a new Space will be created on each page load. Also, add the content here to your styles.css
.
2. Initialize Flatfile
In yourApp.tsx
, at minimum, you’ll need to pass in the publishableKey
. Also, add the content here to your index.tsx
, tsconfig.json
, manifest.json
, and config-overries.js
.
3. Start your client
- Update your package.json to include this script:
- Now, start your front end by heading to terminal and running the following command.
You’ll get an alert: We’re unable to detect target browsers. Would you like to
add the defaults to your package.json? Say yes.
- To see that it’s running, visit: https://localhost:3000 (or the port it is running on) and you should see your page and a button. Click the button and see that an empty Space gets created.
4. Build a Workbook
Now, let's build a Workbook inside the Space for next time.- Add a
src/workbook.ts
file with this simple Blueprint. - Update
App.tsx
to import the Workbook.
5. Transform Data
Next, we'll listen for data changes and respond using an event listener.- Add a
src/listener.ts
file with this simplerecordHook
. - Update
App.tsx
to import the listener.
6. Match your brand
By attaching athemeConfig
to flatfileOptions
in src/App.tsx
, we will now override colors in your Space to match your brand. See all of the options here in the Theming Reference.
src/App.tsx (snippet)
7. Set the destination
Finally, let's get the data out of our system and to your destination.- Update your
listener.ts
with this simple submit action.
src/listener.ts