The embedded ontology enables applications to sync ontology data locally, allowing users to interact with data without network connectivity and install applications as progressive web apps ↗ (PWAs). This guide offers a walkthrough for creating a Foundry application with offline support using the embedded ontology React template in the @palantir/lohi-ts library.
Before starting, complete standard application setup with the steps below.
To support offline functionality, your application will use WebAssembly (Wasm). You must configure the content security policy to allow Wasm execution.
'wasm-unsafe-eval', including the single quotes.
Without this CSP configuration, your deployed application will fail to initialize. This must be configured before deploying.
Use the repository bootstrapper to create your repository with the ontology React template.

The template will be configured with the following backing repositories:
osdk-templates-bundle: Provides the embedded ontology (lohi-ts) application template.lohi-asset-bundle: Contains the lohi-ts library and dependencies.nodejs-bundle: Node.js runtime for CI/CD..env.production in your repository.VITE_FOUNDRY_REDIRECT_URL with your website subdomain, substituting your-enrollment with your enrollment name.Copied!1VITE_FOUNDRY_REDIRECT_URL=https://your-subdomain.your-enrollment.palantirfoundry.com/auth/callback
Ensure that your Developer Console OAuth configuration includes this redirect URL.
The template comes with a pre-configured client.ts file that uses lohi-ts. You need to specify which ontology objects to sync for offline use.
src/client.ts.Copied!1import { Employee, Task } from "@your-app/sdk";import { type ObjectTypeDefinition } from "@osdk/client";
syncObjects array with the objects you want available offline:Copied!1const syncObjects: ObjectTypeDefinition[] = [Employee, Task];
Only include the objects that users need offline access to. Syncing too many objects can impact initial load time and storage usage.
The template includes a working example in src/components/LohiExample.tsx that demonstrates the sync pattern.
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19import { SyncState, type Client } from "@palantir/lohi-ts";import { useOsdkClient } from "@osdk/react"; function YourComponent() { const client = useOsdkClient() as Client; const [syncState, setSyncState] = useState<SyncState | null>(null); useEffect(() => { (async () => { const currentState = await client.syncState(); setSyncState(currentState); if (currentState !== SyncState.Ready) { await client.sync(); setSyncState(await client.syncState()); } })(); }, [client]); *// Your component logic here* }
For more details on using an embedded ontology in your application, refer to the README.md in your generated repository.
With the template configured, you can now develop your application logic offline, or in a VS Code workspace.
The template is pre-configured with the following features:
@palantir/lohi-ts dependency.lohi-ts Vite plugin configured for Wasm optimization.You can use the tag version feature in a Foundry VS Code workspace or code repository to create a version tag for your application’s release.

You can also deploy your application using git tags if you are working offline:
Copied!1 2git tag 1.0.0 git push origin tag 1.0.0
Code Repositories will automatically build and deploy your application to the configured subdomain. For more details on deployment options, refer to Deploy a custom application on Foundry.
Once your application is deployed, users can install it as a progressive web app for offline access and a native-like experience.
Navigate to your deployed application in a supported browser. This includes Chrome, Edge, Safari, or other Chromium-based browsers.
Look for the Install or Add to Home Screen prompt:
Select Install and follow the browser's prompts.
The application will be installed and can be launched from your device like a native application.
After installation, you can launch the application from your installed apps or home screen. The application will work offline using synced ontology data. When connectivity is restored, the application will automatically sync the latest data. Users can continue working with local data even without network access.
Only the ontology objects configured in syncObjects will be available offline. Ensure that you have configured the appropriate objects before users install the application.
Ensure that your Foundry enrollment allows CORS for the following:
http://localhost:8080Configure CORS in Control Panel if you have permission, or contact your Foundry administrator.
If you see TypeScript errors when calling client.sync() or client.syncState(), ensure that you are casting the client as follows:
Copied!1const client = useOsdkClient() as Client;
If you see build errors related to the dev-dist directory, delete the directory. This directory is automatically generated and is already included in the .gitignore.