# AngularJS with OSDK

**URL:** <https://community.palantir.com/t/angularjs-with-osdk/1717>\
**Category:** Ask the Community\
**Tags:** osdk, code-workspaces\
**Created:** [October 31, 2024, 2:58pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717 "2024-10-31T14:58:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanphelippe](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jeanphelippe](https://community.palantir.com/u/jeanphelippe)\
**Post date:** [October 31, 2024, 2:58pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717/1 "2024-10-31T14:58:24Z")

</div>

Is there a way to use OSDK with the AngularJS framework instead of React?

---

<div class="post-metadata">

**Author:** ![jeanphelippe](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jeanphelippe](https://community.palantir.com/u/jeanphelippe)\
**Post date:** [October 31, 2024, 3:05pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717/2 "2024-10-31T15:05:40Z")

</div>

Yes. You can use AngularJS as the Typescript framework while leveraging the benefits of OSDK.

## 1) Start a new application in the Developer Console

Follow the documentation to [start a new application](https://www.palantir.com/docs/foundry/ontology-sdk/how-to-bootstrapping-typescript/) using the Developer Console.  
The boilerplate code comes already with React template (for now, stay tuned for updates at [Annoucements](https://www.palantir.com/docs/foundry/announcements/)). The dev server uses Vite.js (https://v2.vitejs.dev/) which does not fully support AngularJS. But with a few modifications it is possible to do so.

Original Palantir OSDK template in React:

 ![Post Image 1](https://canada1.discourse-cdn.com/palantir/original/2X/d/dbf08dd1f8d7c66426354ed38a073a45411adedb.png)

## 2) Modify the current template

There many options to circunvent the Vite.js limitation. One option is to use the **Analog.js** meta-framework. Analog.js comes with an integration with Vite.js using the `@analogjs/vite-plugin-angular` plugin.

Firstly, we need to remove in the `package.json` file the React dependencies and add both Analog.js and AngularJS dependencies. **Versions might differ from the time you are reading this post.**

Remove the below dependencies:

```auto
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^6.23.1"

```

Add the below dependencies instead

```auto
"@angular/core": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
"@angular/platform-browser": "^17.3.0",
"@angular/platform-browser-dynamic": "^17.3.0",
"@angular/router": "^17.3.0",
"zone.js": "~0.14.0"

```

In devDependencies, remove the below:

```auto
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitejs/plugin-react": "^4.2.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6"

```

And add the below devDependencies:

```auto
"@analogjs/platform": "^1.5.0",
"@analogjs/vite-plugin-angular": "^1.5.0",
"@angular-devkit/build-angular": "^17.0.0",
"@angular-devkit/core": "^17.0.0",
"@angular-devkit/schematics": "^17.0.0",
"@angular/cli": "^17.3.8",
"@angular/compiler-cli": "^17.0.0",
"@ngtools/webpack": "^17.0.0",

```

Your dependencies should look like something like this:

```auto
"dependencies": {
    "@angular-app-v3/sdk": "latest",
    "@osdk/client": "^2.0.8",
    "@osdk/oauth": "^1.0.0",
    "@angular/core": "^17.3.0",
    "@angular/common": "^17.3.0",
    "@angular/compiler": "^17.3.0",
    "@angular/platform-browser": "^17.3.0",
    "@angular/platform-browser-dynamic": "^17.3.0",
    "@angular/router": "^17.3.0",
    "zone.js": "~0.14.0"
  },
  "devDependencies": {
    "@analogjs/platform": "^1.5.0",
    "@analogjs/vite-plugin-angular": "^1.5.0",
    "@angular-devkit/build-angular": "^17.0.0",
    "@angular-devkit/core": "^17.0.0",
    "@angular-devkit/schematics": "^17.0.0",
    "@angular/cli": "^17.3.8",
    "@angular/compiler-cli": "^17.0.0",
    "@ngtools/webpack": "^17.0.0",
    "@types/node": "^20.12.12",
    "@typescript-eslint/eslint-plugin": "^7.16.0",
    "@typescript-eslint/parser": "^7.16.0",
    "eslint": "^8.57.0",
    "typescript": "~5.4.2",
    "vite": "^5.4.8",
    "vitest": "^2.1.2"
  }

```

Then run the below command in the terminal

```auto
npm install

```

If you face any dependency conflict error you can either check the versions above and the error message with the help of AIP Assist or make sure you don’t have other versions already installed removing the old ones using the below command:

```auto
rm -rf node_modules package-lock.json
npm install

```

The final package.json should look like something like this:

```auto
{
  "name": "angular-app",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "dev:remote": "vite --mode code-workspaces",
    "build": "tsc && vite build",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "test": "vitest run",
    "preview": "vite preview"
  },
  "dependencies": {
    "@angular-app-v3/sdk": "latest",
    "@osdk/client": "^2.0.8",
    "@osdk/oauth": "^1.0.0",
    "@analogjs/router": "^1.5.0",
    "@angular/core": "^17.3.0",
    "@angular/common": "^17.3.0",
    "@angular/compiler": "^17.3.0",
    "@angular/platform-browser": "^17.3.0",
    "@angular/platform-browser-dynamic": "^17.3.0",
    "@angular/router": "^17.3.0",
    "zone.js": "~0.14.0"
  },
  "devDependencies": {
    "@analogjs/platform": "^1.5.0",
    "@analogjs/vite-plugin-angular": "^1.5.0",
    "@angular-devkit/build-angular": "^17.0.0",
    "@angular-devkit/core": "^17.0.0",
    "@angular-devkit/schematics": "^17.0.0",
    "@angular/cli": "^17.3.8",
    "@angular/compiler-cli": "^17.0.0",
    "@ngtools/webpack": "^17.0.0",
    "@types/node": "^20.12.12",
    "@typescript-eslint/eslint-plugin": "^7.16.0",
    "@typescript-eslint/parser": "^7.16.0",
    "eslint": "^8.57.0",
    "typescript": "~5.4.2",
    "vite": "^5.4.8",
    "vitest": "^2.1.2"
  }
}

```

## 3) Modify the Vite config files

Now we need to modify the below files accordingly to the Analog.JS docs (https://analogjs.org/docs/packages/vite-plugin-angular/overview)

### Replace vite.config.js to the below

```auto
import { defineConfig } from 'vite';
import angular from '@analogjs/vite-plugin-angular';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [angular()],
  base:
    process.env.NODE_ENV === "development"
      ? process.env.DEV_SERVER_BASE_PATH
      : undefined,
  server: {
    port: Number(process.env.DEV_SERVER_PORT ?? 8080),
    host: process.env.DEV_SERVER_HOST,
  },
});

```

### Create a new tsconfig.app.json file

```auto
{
    "extends": "./tsconfig.json",
    "compileOnSave": false,
    "compilerOptions": {
      "baseUrl": "./",
      "outDir": "./dist/out-tsc",
      "forceConsistentCasingInFileNames": true,
      "strict": true,
      "noImplicitOverride": true,
      "noPropertyAccessFromIndexSignature": true,
      "noImplicitReturns": true,
      "noFallthroughCasesInSwitch": true,
      "sourceMap": true,
      "declaration": false,
      "downlevelIteration": true,
      "experimentalDecorators": true,
      "moduleResolution": "node",
      "importHelpers": true,
      "noEmit": false,
      "target": "es2020",
      "module": "es2020",
      "lib": ["es2020", "dom"],
      "skipLibCheck": true
    },
    "angularCompilerOptions": {
      "enableI18nLegacyMessageIdFormat": false,
      "strictInjectionParameters": true,
      "strictInputAccessModifiers": true,
      "strictTemplates": true
    },
    "files": [],
    "include": ["src/**/*.ts"]
  }

```

## 4) Setup your AngularJS app

Now that the dependencies are installed we need to remove the old React files from the ./src/ folder and add the AngularJS files using the Analog.JS boilerplate. For reference, get yourself familiarized with the Analog.JS docs especially the routing process (https://analogjs.org/docs/features/routing/overview).

Firstly, we need to modify the index.html to use Angular tags instead of React tags:

### index.html

```auto
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/angular_logo.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Ontology SDK + Angular</title>
  </head>
  <body>
    <app-root></app-root>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>

```

Now let’s add our files to the src folder. Below is just an example, but it will depend on how you want to setup your Angular project. You can find more ideas on the official Angular docs(https://v17.angular.io/start#create-the-sample-project).

```auto
src/
  app/
    app.module.ts
    app.component.ts
    app.component.html
    app.component.css
  main.ts
index.html

```

### main.ts

```auto
import 'zone.js'; // Add this line
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));

```

### app.module.ts

```auto
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

```

### app.component.ts

```auto
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `<h1>Welcome to Ontology SDK + Angular</h1>`,
  styles: []
})
export class AppComponent { }

```

Finally, just run the below command

```auto
npm run dev:remote

```

 ![Post Image2](https://canada1.discourse-cdn.com/palantir/original/2X/1/1805307731468666fc409fd45a3099e6d02d137b.png)

And inspired on the current boilerplate you can easily reassemble the components in AngularJS:

 ![Post Image 3](https://canada1.discourse-cdn.com/palantir/original/2X/a/ae664479eb8ede8075b12ba2695f91f2b6187001.png)

---

<div class="post-metadata">

**Author:** ![alfonsogi](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@alfonsogi](https://community.palantir.com/u/alfonsogi)\
**Post date:** [November 6, 2024, 2:17pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717/3 "2024-11-06T14:17:04Z")

</div>

Thank you @jeanphelippe your post is quite helpful. The amount of detail you shared makes a great difference.

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [April 10, 2025, 6:52pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717/4 "2025-04-10T18:52:21Z")

</div>

Automatically bumped on April 10, 2025, 6:52pm UTC



---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [December 24, 2025, 3:05pm UTC](https://community.palantir.com/t/angularjs-with-osdk/1717/5 "2025-12-24T15:05:19Z")

</div>

Automatically bumped on December 24, 2025, 3:05pm UTC


