2024-04-25 14:56:13 +03:00
---
2024-07-21 12:01:25 +03:00
description: How to use es-toolkit
2024-04-25 14:56:13 +03:00
prev:
text: Introduction to es-toolkit
link: ./intro.md
next:
text: Impact on Bundle Size
link: ./bundle-size
---
2024-06-04 11:19:26 +03:00
2024-07-21 12:01:25 +03:00
# Installation & Usage
2024-04-25 14:56:13 +03:00
2024-06-30 08:53:42 +03:00
es-toolkit is available via [npm ](https://npmjs.com/package/es-toolkit ) for Node.js and Bun, and through [JSR ](https://jsr.io/@es-toolkit/es-toolkit ) for Deno.
2024-04-25 14:56:13 +03:00
2024-07-21 12:01:25 +03:00
You can also use es-toolkit in browsers by [importing them in CDNs ](#browsers ).
2024-06-04 11:19:26 +03:00
## Node.js
2024-04-25 14:56:13 +03:00
es-toolkit supports Node.js 18 or later. Install es-toolkit with the following command:
2024-07-01 01:10:04 +03:00
::: code-group
```sh [npm]
2024-04-25 14:56:13 +03:00
npm install es-toolkit
2024-07-01 01:10:04 +03:00
```
```sh [pnpm]
2024-09-14 08:08:18 +03:00
pnpm add es-toolkit
2024-04-25 14:56:13 +03:00
```
2024-07-01 01:10:04 +03:00
```sh [yarn]
yarn add es-toolkit
```
:::
2024-06-04 11:19:26 +03:00
## Deno
2024-04-25 14:56:13 +03:00
2024-06-30 08:53:42 +03:00
es-toolkit is also available via [JSR ](https://jsr.io/@es-toolkit/es-toolkit ) for Deno. To install es-toolkit, use the following command:
2024-06-30 07:43:58 +03:00
```sh
deno add @es -toolkit/es-toolkit
```
2024-06-30 07:50:43 +03:00
Note that the package name includes an additional scope, distinct from npm, as per JSR restrictions.
2024-04-25 14:56:13 +03:00
```typescript
2024-06-30 07:43:58 +03:00
import { sum } from '@es-toolkit/es-toolkit';
sum([1, 2, 3]);
2024-04-25 14:56:13 +03:00
```
2024-06-04 11:19:26 +03:00
## Bun
2024-04-25 14:56:13 +03:00
es-toolkit is also available on Bun. You can install it via the following command:
```sh
bun add es-toolkit
2024-06-04 11:19:26 +03:00
```
2024-07-20 05:41:29 +03:00
## Browsers
2024-07-20 05:50:25 +03:00
You can find es-toolkit on CDNs such as [jsdelivr ](https://www.jsdelivr.com ), [unpkg ](https://unpkg.com ). We define `_` to include all functions, similar to Lodash.
2024-07-20 05:41:29 +03:00
::: code-group
```html [jsdelivr]
2024-07-20 05:50:25 +03:00
< script src = "https://cdn.jsdelivr.net/npm/es-toolkit@%5E1" > < / script >
2024-07-20 05:41:29 +03:00
< script >
var arr = _.chunk([1, 2, 3, 4, 5, 6], 3);
< / script >
```
```html [unpkg]
2024-07-20 05:50:25 +03:00
< script src = "https://unpkg.com/es-toolkit@%5E1" > < / script >
2024-07-20 05:41:29 +03:00
< script >
var arr = _.chunk([1, 2, 3, 4, 5, 6], 3);
< / script >
```
:::
2024-07-20 05:50:25 +03:00
es-toolkit is also available on [esm.sh ](https://esm.sh ) for modern browsers.
::: code-group
```html [esm.sh]
< script type = "importmap" >
{
"imports": {
"es-toolkit": "https://esm.sh/es-toolkit@%5E1"
}
}
< / script >
< script type = "module" >
import { chunk } from 'es-toolkit';
2024-10-01 08:52:25 +03:00
2024-07-20 05:50:25 +03:00
chunk([1, 2, 3, 4, 5, 6], 3);
< / script >
```
:::