# amp-toolbox-runtime-version

> AMP Runtime versions

Latest version **1.2.0-alpha.2** (published 2019-06-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install amp-toolbox-runtime-version
pnpm add amp-toolbox-runtime-version
yarn add amp-toolbox-runtime-version
bun add amp-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 | 1.2.0-alpha.2 |
| Published | 2019-06-04 |
| First published | 2018-01-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 459 |
| Author | AMPHTML Team |
| Maintainers | amp-toolbox |
| Keywords | amp |

## Links

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

## Dependencies (1)

- [amp-toolbox-core](https://npm.io/package/amp-toolbox-core.md) ^1.2.0-alpha.2

## Recent versions

- 1.2.0-alpha.2 (latest) — 2019-06-04
- 1.2.0-alpha.1 (canary) — 2019-05-20
- 1.2.0-alpha.0 — 2019-05-07
- 0.2.7 — 2019-04-24
- 0.2.6 — 2019-03-13
- 0.2.5 — 2019-02-22
- 0.2.4 — 2019-02-08
- 0.2.3 — 2018-11-26
- 0.2.2 — 2018-11-15
- 0.2.1 — 2018-09-13
- 0.1.0 — 2018-02-01
- 0.0.2 — 2018-01-16

## README

# AMP Runtime Version

[![npm version](https://badge.fury.io/js/amp-toolbox-runtime-version.svg)](https://badge.fury.io/js/amp-toolbox-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 amp-toolbox-runtime-version
```

## Usage

Basic usage:

```js
const runtimeVersion = require('amp-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/amp-toolbox-runtime-version · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
