# @ampproject/toolbox-runtime-version

> AMP Runtime versions

Latest version **2.10.1** (published 2024-06-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ampproject/toolbox-runtime-version
pnpm add @ampproject/toolbox-runtime-version
yarn add @ampproject/toolbox-runtime-version
bun add @ampproject/toolbox-runtime-version
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.10.1 |
| Published | 2024-06-14 |
| First published | 2019-06-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 459 |
| Author | AMPHTML Team |
| Maintainers | ampproject-admin, kristoferbaxter, jridgewell, choumx, amp-toolbox, fstanis, erwinmombay, samouri, caroqliu, rsimha, dvoytenko, patrickkettner, alanorozco, kdwan, ampprojectbot, esth |
| Keywords | amp |

## Links

- npm: https://www.npmjs.com/package/@ampproject/toolbox-runtime-version
- Repository: https://github.com/ampproject/amp-toolbox
- Homepage: https://github.com/ampproject/amp-toolbox/tree/main/packages/runtime-version
- Issues: https://github.com/ampproject/amp-toolbox/issues
- npm.io page: https://npm.io/package/@ampproject/toolbox-runtime-version

## Dependencies (1)

- [@ampproject/toolbox-core](https://npm.io/package/@ampproject/toolbox-core.md) 2.10.0

## Recent versions

- 2.10.1 (latest) — 2024-06-14
- 3.0.0-canary.2 (canary) — 2022-01-11
- 2.7.1-alpha.0 (alpha) — 2020-12-01
- 1.1.0-beta.0 (beta) — 2019-08-29
- 2.10.0 — 2024-06-13
- 2.9.0 — 2022-06-23
- 2.8.0 — 2021-05-31
- 2.8.0-canary.15 — 2021-03-30
- 2.8.0-canary.9 — 2021-03-22
- 2.8.0-canary.0 — 2021-02-12
- 2.7.4 — 2020-12-23
- 2.7.2 — 2020-12-15
- 2.7.1 — 2020-12-02
- 2.7.0-alpha.1 — 2020-08-19
- 2.6.0 — 2020-08-10
- … 27 more at https://npm.io/package/@ampproject/toolbox-runtime-version/versions

## README

# AMP Runtime Version

[![npm version](https://badge.fury.io/js/%40ampproject%2Ftoolbox-runtime-version.svg)](https://badge.fury.io/js/%40ampproject%2Ftoolbox-runtime-version)

Use it to query `cdn.ampproject.org` for the current release or canary version of the AMP Runtime. Uses a stale-while-revalidate caching strategy to avoid network requests in the critical path.

You can use the API to re-write AMP runtime URLs to their versioned counter parts to improve browser caching, e.g. to replace:

```
https://cdn.ampproject.org/v0.css
```

with:

```
https://cdn.ampproject.org/rtv/001515617716922/v0.css
```


## Installation

Install via:

```sh
npm install @ampproject/toolbox-runtime-version
```

## Usage

Basic usage:

```js
const runtimeVersion = require('@ampproject/toolbox-runtime-version');

// Release version
runtimeVersion.currentVersion().then(version => {
  console.log(version);
});

// Canary version
runtimeVersion.currentVersion({canary: true}).then(version => {
  console.log(version);
});

// Rewriting cache URLs
const ampRuntimeUrl = 'https://cdn.ampproject.org/v0.js';
const version = await runtimeVersion.currentVersion();
const versionedAmpRuntimeUrl = ampRuntimeUrl.replace(
  'https://cdn.ampproject.org/',
  'https://cdn.ampproject.org/rtv/' + version + '/'
);
console.log(versionedAmpRuntimeUrl);
```

---
_Source: https://npm.io/package/@ampproject/toolbox-runtime-version · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
