Local development uses Vite (hot module replacement, HTTPS on localhost) and npm. The Vite plugin API documentsDocumentation Index
Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
Use this file to discover all available pages before exploring further.
fusionOpenPlugin and the CDF development URL pattern.
Start the dev server
After you create your Flows custom app and install dependencies, start the dev server to run the app locally:- Generate HTTPS certificates (first run only).
- Start the Vite dev server on
https://localhost:3001(or the next available port if 3001 is already in use). - Open your app in CDF (when configured).
localhost:3001. The browser needs to reach the local dev server, but authentication requires the CDF parent window.
How it works
Users sign in through CDF. Your app runs in an iframe inside CDF, andconnectToHostApp() from @cognite/app-sdk handles authentication by communicating with the host window. Use the returned HostAppAPI to get an access token and construct an authenticated Cognite SDK.
TanStack Query (React Query) is included for data fetching. Combine it with connectToHostApp() to call the SDK (for example, assets or time series) with loading and error handling in React. See the Auth API for usage and examples.
Development URL
The dev server can open your app at:{org} and {project} come from your app.json configuration.
Hot module replacement
Changes to your code appear quickly without losing state:Configuration
Change the port
Editvite.config.ts:
Disable auto-open
RemovefusionOpenPlugin from vite.config.ts if you do not want the browser to open automatically:
Troubleshooting
App will not start
Check your Node.js version Flows requires Node.js 20.19 or higher:ERR_REQUIRE_ESM error
If you see an error about require() of an ES module, your Node.js version is too old. Update to Node.js 20.19 or later.
Dependencies not installed
Certificate errors
App does not load in CDF If you runnpm start but the app fails to load in CDF:
- Open the localhost URL in your browser (for example, https://localhost:3001).
- Select Advanced, then Proceed to accept the certificate.
- Return to CDF and refresh the page.
.vite-plugin-mkcert folder and restart the dev server.
Port already in use
Further reading
- Get started with Flows — Create an app and prerequisites.
- Deploy your Flows app — Interactive deploy and CI/CD.
- Auth API —
connectToHostApp,HostAppAPI, and helpers. - Vite plugin API —
fusionOpenPluginand development URLs.