publishableKey: Get from Platform Dashboard → Developer SettingsFor authentication guidance including JWT tokens and user management, see Advanced Configuration.
The example below will open an empty space. To create the sheet your users
should land on, you’ll want to create a workbook as shown further down this
page.
The publishableKey is designed exclusively for initializing FlatfileProvider. To make API requests, use the accessToken from the useFlatfileInternal hook.
Use useFlatfileInternal to access the accessToken for making authenticated API calls:
Copy
Ask AI
import { useEffect, useState } from "react";import { useFlatfileInternal } from "@flatfile/react";import { FlatfileClient } from "@flatfile/api";function MyComponent() { const { accessToken, sessionSpace } = useFlatfileInternal(); const [data, setData] = useState([]); useEffect(() => { // Wait for the space to be created and token to be available if (!accessToken || !sessionSpace?.id) return; // Initialize the API client with the accessToken const api = new FlatfileClient({ token: accessToken }); const fetchData = async () => { try { const workbooks = await api.workbooks.list({ spaceId: sessionSpace.id }); setData(workbooks.data); } catch (error) { console.error("API Error:", error); } }; fetchData(); }, [accessToken, sessionSpace?.id]); return <div>{data.length} workbooks found</div>;}
// Create Space on your serverconst space = await api.spaces.create({ name: "User Import", workbooks: [workbookConfig],});// Pass spaceId to your React appres.json({ spaceId: space.data.id, token: space.data.accessToken });