diff --git a/.changeset/better-dingos-bet.md b/.changeset/better-dingos-bet.md new file mode 100644 index 0000000000..9695528f17 --- /dev/null +++ b/.changeset/better-dingos-bet.md @@ -0,0 +1,6 @@ +--- +"@gradio/client": patch +"gradio": patch +--- + +feat:Add CDN installation to JS docs diff --git a/client/js/README.md b/client/js/README.md index a475295a2a..2ed35fdf34 100644 --- a/client/js/README.md +++ b/client/js/README.md @@ -1,6 +1,7 @@ ## JavaScript Client Library -A JavaScript (and TypeScript) Client to call Gradio APIs. +Interact with Gradio APIs using our JavaScript (and TypeScript) client. + ## Installation @@ -10,6 +11,12 @@ The Gradio JavaScript Client is available on npm as `@gradio/client`. You can in npm i @gradio/client ``` +Or, you can include it directly in your HTML via the jsDelivr CDN: + +```shell + +``` + ## Usage The JavaScript Gradio Client exposes the Client class, `Client`, along with various other utility functions. `Client` is used to initialise and establish a connection to, or duplicate, a Gradio app. diff --git a/guides/08_gradio-clients-and-lite/02_getting-started-with-the-js-client.md b/guides/08_gradio-clients-and-lite/02_getting-started-with-the-js-client.md index df18ec1816..9304149be2 100644 --- a/guides/08_gradio-clients-and-lite/02_getting-started-with-the-js-client.md +++ b/guides/08_gradio-clients-and-lite/02_getting-started-with-the-js-client.md @@ -29,14 +29,26 @@ The Gradio Client works with any hosted Gradio app, whether it be an image gener **Prequisites**: To use the Gradio client, you do _not_ need to know the `gradio` library in great detail. However, it is helpful to have general familiarity with Gradio's concepts of input and output components. -## Installation +## Installation via npm -The lightweight `@gradio/client` package can be installed from the npm registry with a package manager of your choice and support node version 18 and above: +Install the @gradio/client package to interact with Gradio APIs using Node.js version >=18.0.0 or in browser-based projects. Use npm or any compatible package manager: ```bash npm i @gradio/client ``` +This command adds @gradio/client to your project dependencies, allowing you to import it in your JavaScript or TypeScript files. + +## Installation via CDN + +For quick addition to your web project, you can use the jsDelivr CDN to load the latest version of @gradio/client directly into your HTML: + +```bash + +``` + +Be sure to add this to the `` of your HTML. This will install the latest version but we advise hardcoding the version in production. You can find all available versions [here](https://www.jsdelivr.com/package/npm/@gradio/client). This approach is ideal for experimental or prototying purposes, though has some limitations. + ## Connecting to a running Gradio App Start by connecting instantiating a `client` instance and connecting it to a Gradio app that is running on Hugging Face Spaces or generally anywhere on the web.