docs: update imports for platforms (#315)

* docs: fix browser import

* docs: add deno.land instructions

As mentioned in issue #314
This commit is contained in:
Daniel Wykerd
2023-02-17 19:53:06 +02:00
committed by GitHub
parent 6b6c80ddf1
commit 9d352b58eb

View File

@@ -112,7 +112,10 @@ yarn add youtubei.js@latest
npm install github:LuanRT/YouTube.js
```
**TODO:** Deno install instructions (deno.land)
When using Deno, you can import YouTube.js directly from deno.land:
```ts
import { Innertube } from 'https://deno.land/x/youtubei/deno.ts';
```
## Usage
Create an InnerTube instance:
@@ -128,8 +131,13 @@ To use YouTube.js in the browser you must proxy requests through your own server
You may provide your own fetch implementation to be used by YouTube.js. Which we will use here to modify and send the requests through our proxy. See [`examples/browser/web`](https://github.com/LuanRT/YouTube.js/tree/main/examples/browser/web) for a simple example using [Vite](https://vitejs.dev/).
```ts
// Pre-bundled version for the web
import { Innertube } from 'youtubei.js/bundle/browser';
// We provide multiple exports for the web.
// Unbundled ESM version
import { Innertube } from 'youtubei.js/web';
// Bundled ESM version
// import { Innertube } from 'youtubei.js/web.bundle';
// Production Bundled ESM version
// import { Innertube } from 'youtubei.js/web.bundle.min';
await Innertube.create({
fetch: async (input: RequestInfo | URL, init?: RequestInit) => {
// Modify the request