# Add the standalone player to a TypeScript project In recent years, TypeScript has become the preferred choice for many developers and organizations. This growth can be attributed to several factors. The language is a superset of JavaScript. It introduces static typing that enhances code quality and catches errors during compile time rather than at runtime. TypeScript also offers intelligent code completion, navigation, and refactoring capabilities to boost developer productivity. Additionally, it supports and transpiles modern JavaScript or ECMAScript 6 (ES6) features to ensure compatibility with older browsers and environments. Lastly, with solid backing from Microsoft, TypeScript has established itself as a robust and scalable solution that provides stability and continuous improvement. This guide describes using TypeScript to integrate the standalone player and its plugins into your development projects. info The `@flowplayer/player` npm package uses TypeScript version 5.4.2. ## Benefits of TypeScript usage The Wowza Flowplayer library and plugins provide full TypeScript support to enhance your development experience. All plugins and entry files include type declaration files that make it easier to use our libraries while taking advantage of these TypeScript features: * **Type safety:** You get accurate type information to improve type checking and type safety when working with our player. This allows TypeScript to catch errors at compile time rather than runtime. Types are self-documenting, for example, clarifying what arguments functions expect and what they return.  * **IntelliSense capabilities:** When integrating our libraries, you can take advantage of autocompletion or IntelliSense features to see what properties or methods are available in your Integrated Development Environment (IDE). Inline documentation makes it faster to work with our player and plugins.  * **Interoperability:** You can smoothly integrate our plugins without guessing how to incorporate them along with the player. TypeScript understands how to import and use these libraries without additional configuration steps or research.  ## Before you start Before you start working with this guide, we make the following assumptions and recommendations: * You have basic knowledge of JavaScript and TypeScript. * You're familiar with the ECMAScript Module (ESM) approach of handling JavaScript modules. * You have Node.js and Node Package Manager (npm) installed on your machine. * You're using Visual Studio Code as your IDE. * Review the [Token configuration](/docs/wowza-flowplayer/player/configure/#token-configuration) section. To authorize the player, you need to configure it with your token. * When working with media from Wowza Video, you must use the [Wowza Video Platform Integration](/docs/wowza-flowplayer/plugins/wowza-video-platform-integration/) plugin. info This guide uses Vite to handle the bundling and development server. If you use this approach, make sure your version of Node.js is compatible with your Vite version. Vite requires Node.js version 18+ or 20+. You can also use another module bundler, such as Webpack, to simplify managing dependencies, importing styles, and optimizing the build process. ## 1. Set up your TypeScript project This section assumes you're creating a new TypeScript project. However, you can skip these steps and continue with the next section if you're working with an existing project. 1. Initialize a new Node.js project by installing Vite and the TypeScript package: ```bash npm create vite@latest flowplayer-ts-project -- --template vanilla-ts ``` When including the `--template` flag in the previous step, you're also setting up the TypeScript configuration by creating a **tsconfig.json** file in the root of your project. This file should be configured for ESM. The configuration may look similar to this: ```json { "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ES2020", "DOM", "DOM.Iterable"], "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "isolatedModules": true, "moduleDetection": "force", "noEmit": true, /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, "include": ["src"] } ``` ```empty-tab ``` With this specific TypeScript configuration, you can automatically import the player plugins by name instead of typing out the exact path. ## 2. Install Wowza Flowplayer We suggest installing the player into your TypeScript project using npm. The player assets exist on npm under the @flowplayer/player package. The `@flowplayer/player` npm package already includes **.d.ts** files so you don't have to separately install the TypeScript **@types** definitions. 1. Move to the current directory for the project you just installed: ```bash cd flowplayer-ts-project ``` 2. To install the latest stable build for Wowza Flowplayer, run the following: ```npm npm install @flowplayer/player ``` ## 3. Update your project Next, update your project and replace your TypeScript and HTML files. This step initializes the player with its configuration values and adds the HTML elements needed to display the player in a web browser. 1. Update your **src/main.ts** file by importing the player library, adding the basic CSS for the player, and initializing the player: ```typescript // Import the player library and basic CSS for the player import flowplayer from "@flowplayer/player"; import "@flowplayer/player/flowplayer.css"; // Initialize the player document.addEventListener("DOMContentLoaded", () => { const player = flowplayer("#player", { // Add placeholder for the media source URL src: "[video-source-url]", // Remove the token if running over localhost token: "[your-player-token]", title: "Elephants Dream", description: "Experimental short film produced by Blender Foundation", }); }); ``` ```empty-tab ``` For more information about the required `token` value, see [Token configuration](/docs/wowza-flowplayer/player/configure/#token-configuration). If you need information about the `src` property, see the [Video source](/docs/wowza-flowplayer/player/configure/#video-source) section. 2. To render the player on a web page, add the following to the **index.html** file at the root of your project: ```html