Reuse a Space when Flatfile is opened.
development
environment.
init
command.
/src
especially in /src/components
. Many of thsese files are configuration files which are mostly set once and not touched again. So while there may be a lot, they won’t be actively managed.
.env
. FLATFILE_API_KEY
is your Secret Key and SPACE_ID
is the Space you want to open in the importer. This can be found on your Dashboard where it lists your Spaces. You may also want to include your PUBLISHABLE_KEY
and ENVIRONMENT_ID
if you want to have your app create new spaces as well.
Note in the below example some of the variables are prefixed with VITE_
. This is because Vite requires the prefix to access them at runtime. The FLATFILE_API_KEY
should never be accessible from the browser for security reasons, and should not have this prefix.
package.json
to start the app. Add the following scripts:
/views/index.html.ejs
This file wil not work before the server is functioning, but is required for the rest of the app to work.
server/index.ts
, you will need to create two routers - One for the homepage and one for the assets. This is because the frontend runs on a different port than you’ll be accessing the app from, so the app will need a bit of help resolving pathing.
Create server/homepageRouter.ts
and server/assetsRouter.ts
as follows, then update server/index.ts
.
src/vite-env.d.ts
file and a src/shims-vue.d.ts
file in order to sort your the declarations. Create them as follows:
src/main.ts
file to mount src/App.vue
to your HTML. Create it and your App Component as shown below.
App.vue
to include the existing space component. It should end up looking like the example below:
src/styles/styles.css
. These should end up looking like the example below:
import './styles/styles.css'
to your src/App.vue
with the other imports to apply the styles.