Overview of Microsoft Teams JavaScript client library
main@microsoft/teams-js package. This repository is a monorepo containing the core library, testing applications (Performance, Functional, and SSR), and analysis tools.repository·main·Indexed 19 days ago
https://github.com/officedev/microsoft-teams-library-jsThe Microsoft Teams JavaScript client library provides the essential SDK for developers to build applications and services that integrate with Microsoft Teams, Outlook, and Office. The repository includes the teams-js package and various test applications for Blazor, SSR (React/NextJS), performance measurement, and general SDK testing.
@microsoft/teams-js package. This repository is a monorepo containing the core library, testing applications (Performance, Functional, and SSR), and analysis tools.bundle-size-tools package is used to compare bundle analysis between two different commits. It automates the process of finding and downloading a baseline commit's analysis from Azure DevOps (ADO) and comparing it against a local bundle analysis to generate a summary of the differences.@microsoft/teams-js package. It contains minimal code that imports the library and is configured with Webpack to generate zipped Webpack stats. These stats allow developers to compare bundle sizes and dependency trees across different commits or changes to track growth or regressions.When using the ApiWithTextInput component, there are two implementation patterns depending on the API requirements:
onClick callback. The component will attempt to parse the input as JSON and pass it to the callback.validateInput and submit callbacks:validateInput: Receives the parsed JSON input. It must throw an exception if input requirements are not met (e.g., a required property is missing). If validation fails, the error is displayed in the Test App UI.submit: Called only if validateInput passes.The Teams client library depends on the Promise type. If you are targeting older browsers or devices that do not support Promises natively (such as IE 11), you must provide a global polyfill like es6-promise in your application.
Important: If using a <script> tag, ensure the polyfill is included and initialized before the Teams client library is initialized.
@microsoft/teams-js package is the primary entry point for developers looking to integrate their applications with the Microsoft Teams platform. For detailed API specifications and usage instructions, refer to the official library reference documentation.The Runtime interface (defined in packages/teams-js/src/public/runtime.ts) describes the capabilities and configuration of the Microsoft Teams host. The Runtime object is versioned so that the teams-js library can correctly parse and support older versions of the host environment.
Versioning follows these rules:
teams-js functionality. This includes renaming or moving supported capabilities, or adding optional properties.You can generate the reference documentation for TeamsJS v2 locally by running the docs script. This can be executed from either the monorepo root or the packages/teams-js directory. The output will be located in packages/teams-js/docs.
pnpm run docsTo build the complete project, including the teams-js package and all included test applications, follow these steps from the repository root:
git clone https://github.com/OfficeDev/microsoft-teams-library-js.gitpnpm install (Note: pnpm@9.0.6 or greater is required).pnpm buildpnpm testgit clone https://github.com/OfficeDev/microsoft-teams-library-js.git
npm install -g pnpm@9.0.6
pnpm install
pnpm build
pnpm testTo build the bundle-size-tools package, use the following command from the package directory:
pnpm buildTo run the SSR Test App in the Orange app, HTTPS is required. You can use either local SSL certificates or ngrok.
Generate certificates: The easiest way is to use the automated script from the monorepo root:
pnpm setup-ssr-app-certThis script checks for mkcert, installs the local CA, and generates certificates in apps/ssr-test-app/certs/.
Manual Setup (if the automated script is not used):
mkcert (e.g., brew install mkcert on macOS).mkcert -install to install the local CA.apps/ssr-test-app/certificates and run mkcert localhost to create localhost.pem and localhost-key.pem.Run the app: From the monorepo root:
pnpm start-ssr-app:https Or from the `ssr-test-app` directory:
```bash
pnpm dev:https # For development
pnpm start:https # For production (requires pnpm build first)The app will be available at https://localhost:3000.
If you prefer not to manage certificates, you can use ngrok to create a secure HTTPS tunnel:
pnpm dev2. Start ngrok in another terminal:
```bash
ngrok http 3000pnpm setup-ssr-app-cert
pnpm start-ssr-app:httpsThe Blazor Test App is a C#/Blazor application used to verify that changes to the teams-js package do not break functionality for C# Teams apps.
To run the app from the monorepo root, you must first ensure the Teams JavaScript client SDK is installed and built, as the app requires the latest compiled MicrosoftTeams.min.js to be present in blazor-test-app/wwwroot/js.
Prerequisites:
teams-js package must be built so that MicrosoftTeams.min.js is generated.MicrosoftTeams.min.js file must be located in blazor-test-app/wwwroot/js (this happens automatically when building from the monorepo root).Steps to run from monorepo root:
Steps to run directly from the project directory:
If you have already built the Teams JavaScript client SDK, you can run it directly from the blazor-test-app directory.
# From the monorepo root
cd {monorepo root}
pnpm install
pnpm build
pnpm start-blazor-app
# OR from the blazor-test-app directory (if SDK is already built)
cd apps/blazor-test-app
pnpm build
pnpm start