Create a new Space every time Flatfile is opened
The DevXP engineering team hosts office hours every Thursday at 11 a.m. Pacific Time where we answer your questions live and help you get up and running with Flatfile. Join us!
For synchronous data import/exchange completed in one session, create a new Space each time Flatfile is opened. This suits situations where a clean slate for every interaction is preferred.
To complete this tutorial, you'll need to retrieve your
Publishable key
from your development
environment.
Note: The Publishable Key is safe to be used in client-side applications as it has limited access to the Flatfile API.
Make a new directory.
Go into that directory.
Follow prompts from the init
command.
Setup your app to look something like this:
In this file structure, your main directory is src
.
Depending on how you want to handle styling your application, you can have a
styles.css
file in your src directory, create sub-directories to contain style
files, or even create directories outside of src
if you prefer. The only
requirement is that the files can be imported into vue files.
The heart of your vue app will be App.vue
, as this will configure and render
your component(s) to the index.html.
Add a button to your application to open Flatfile in a modal. Pass in your
publishableKey
and a new Space will be created on each page load. Optionally,
add the content here to your styles.css
.
In your environment file, you’ll need to define your keys. In this example, you
will need your publishableKey
. You can find these under “Developer settings”
when logged into platform.flatfile.com.
You can create your .env
file via the template below, as well as your
App.vue
, tsconfig.json
, tsconfig.node.json
, and vite.config.ts
, which
are the remaining top-level config files. After these are initialized properly
we can configure the app files under src
.
In your App.vue
you’ll need to pass in a minimum of the publishableKey
from
your .env
.
Also, add the content here to your main.ts
, and vite-env.d.ts
. Optionally
you can also add shims-vue.d.ts
if you have the need.
Your console should display a message like the following:
Now, let’s build a Workbook inside the Space for next time.
Add your config.ts
file, and place the following code in it. After you have
done so, import the configuration to App.vue
, and update spaceProps
to have
the value of config
under workbook
(this will be around line 36
). This
config file has the configuration settings for your workbook, so feel free to
edit however necessary to meet your needs.
Next, we’ll listen for data changes and respond using an event listener.
src/listener.ts
file with this simple recordHook
.App.tsx
to import the listener.Once you add this code, when a change occurs, we’ll log the entered first name and update the last name to “Rock.” You’ll immediately see this begin to work when you add or update any records. Learn more about Handling Data
By attaching a themeConfig
to spaceProps
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.
You can stop here or explore additional configuration options:
Find this Vue.js example project in the Flatfile GitHub repository.
Create a new Space every time Flatfile is opened
The DevXP engineering team hosts office hours every Thursday at 11 a.m. Pacific Time where we answer your questions live and help you get up and running with Flatfile. Join us!
For synchronous data import/exchange completed in one session, create a new Space each time Flatfile is opened. This suits situations where a clean slate for every interaction is preferred.
To complete this tutorial, you'll need to retrieve your
Publishable key
from your development
environment.
Note: The Publishable Key is safe to be used in client-side applications as it has limited access to the Flatfile API.
Make a new directory.
Go into that directory.
Follow prompts from the init
command.
Setup your app to look something like this:
In this file structure, your main directory is src
.
Depending on how you want to handle styling your application, you can have a
styles.css
file in your src directory, create sub-directories to contain style
files, or even create directories outside of src
if you prefer. The only
requirement is that the files can be imported into vue files.
The heart of your vue app will be App.vue
, as this will configure and render
your component(s) to the index.html.
Add a button to your application to open Flatfile in a modal. Pass in your
publishableKey
and a new Space will be created on each page load. Optionally,
add the content here to your styles.css
.
In your environment file, you’ll need to define your keys. In this example, you
will need your publishableKey
. You can find these under “Developer settings”
when logged into platform.flatfile.com.
You can create your .env
file via the template below, as well as your
App.vue
, tsconfig.json
, tsconfig.node.json
, and vite.config.ts
, which
are the remaining top-level config files. After these are initialized properly
we can configure the app files under src
.
In your App.vue
you’ll need to pass in a minimum of the publishableKey
from
your .env
.
Also, add the content here to your main.ts
, and vite-env.d.ts
. Optionally
you can also add shims-vue.d.ts
if you have the need.
Your console should display a message like the following:
Now, let’s build a Workbook inside the Space for next time.
Add your config.ts
file, and place the following code in it. After you have
done so, import the configuration to App.vue
, and update spaceProps
to have
the value of config
under workbook
(this will be around line 36
). This
config file has the configuration settings for your workbook, so feel free to
edit however necessary to meet your needs.
Next, we’ll listen for data changes and respond using an event listener.
src/listener.ts
file with this simple recordHook
.App.tsx
to import the listener.Once you add this code, when a change occurs, we’ll log the entered first name and update the last name to “Rock.” You’ll immediately see this begin to work when you add or update any records. Learn more about Handling Data
By attaching a themeConfig
to spaceProps
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.
You can stop here or explore additional configuration options:
Find this Vue.js example project in the Flatfile GitHub repository.