Skip to content

Commit 607e415

Browse files
authored
Document non-npm approaches to installing SignalR JS client library (#17685)
* Document non-npm approaches to installing SignalR JS client library * Add @aspnet CDN links * Change dev langs * Verbiage tweaks * React to feedback
1 parent 3d77cdf commit 607e415

1 file changed

Lines changed: 45 additions & 13 deletions

File tree

aspnetcore/signalr/javascript-client.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Overview of ASP.NET Core SignalR JavaScript client.
55
monikerRange: '>= aspnetcore-2.1'
66
ms.author: bradyg
77
ms.custom: mvc
8-
ms.date: 11/12/2019
8+
ms.date: 04/08/2020
99
no-loc: [SignalR]
1010
uid: signalr/javascript-client
1111
---
@@ -19,38 +19,70 @@ The ASP.NET Core SignalR JavaScript client library enables developers to call se
1919

2020
## Install the SignalR client package
2121

22-
The SignalR JavaScript client library is delivered as an [npm](https://www.npmjs.com/) package. If you're using Visual Studio, run `npm install` from the **Package Manager Console** while in the root folder. For Visual Studio Code, run the command from the **Integrated Terminal**.
22+
The SignalR JavaScript client library is delivered as an [npm](https://www.npmjs.com/) package. The following sections outline different ways to install the client library.
23+
24+
### Install with npm
25+
26+
If using Visual Studio, run the following commands from **Package Manager Console** while in the root folder. For Visual Studio Code, run the following commands from the **Integrated Terminal**.
2327

2428
::: moniker range=">= aspnetcore-3.0"
2529

26-
```console
27-
npm init -y
28-
npm install @microsoft/signalr
29-
```
30+
```bash
31+
npm init -y
32+
npm install @microsoft/signalr
33+
```
3034

3135
npm installs the package contents in the *node_modules\\@microsoft\signalr\dist\browser* folder. Create a new folder named *signalr* under the *wwwroot\\lib* folder. Copy the *signalr.js* file to the *wwwroot\lib\signalr* folder.
3236

3337
::: moniker-end
3438

3539
::: moniker range="< aspnetcore-3.0"
3640

37-
```console
38-
npm init -y
39-
npm install @aspnet/signalr
40-
```
41+
```bash
42+
npm init -y
43+
npm install @aspnet/signalr
44+
```
4145

4246
npm installs the package contents in the *node_modules\\@aspnet\signalr\dist\browser* folder. Create a new folder named *signalr* under the *wwwroot\\lib* folder. Copy the *signalr.js* file to the *wwwroot\lib\signalr* folder.
4347

4448
::: moniker-end
4549

46-
## Use the SignalR JavaScript client
47-
48-
Reference the SignalR JavaScript client in the `<script>` element.
50+
Reference the SignalR JavaScript client in the `<script>` element. For example:
4951

5052
```html
5153
<script src="~/lib/signalr/signalr.js"></script>
5254
```
5355

56+
### Use a Content Delivery Network (CDN)
57+
58+
To use the client library without the npm prerequisite, reference a CDN-hosted copy of the client library. For example:
59+
60+
```html
61+
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/3.1.3/signalr.min.js"></script>
62+
```
63+
64+
The client library is available on the following CDNs:
65+
66+
::: moniker range=">= aspnetcore-3.0"
67+
68+
* [cdnjs](https://cdnjs.com/libraries/microsoft-signalr)
69+
* [jsDelivr](https://www.jsdelivr.com/package/npm/@microsoft/signalr)
70+
* [unpkg](https://unpkg.com/@microsoft/signalr@next/dist/browser/signalr.min.js)
71+
72+
::: moniker-end
73+
74+
::: moniker range="< aspnetcore-3.0"
75+
76+
* [cdnjs](https://cdnjs.com/libraries/aspnet-signalr)
77+
* [jsDelivr](https://www.jsdelivr.com/package/npm/@aspnet/signalr)
78+
* [unpkg](https://unpkg.com/@aspnet/signalr@next/dist/browser/signalr.min.js)
79+
80+
::: moniker-end
81+
82+
### Install with LibMan
83+
84+
[LibMan](xref:client-side/libman/index) can be used to install specific client library files from the CDN-hosted client library. For example, only add the minified JavaScript file to the project. For details on that approach, see [Add the SignalR client library](xref:tutorials/signalr#add-the-signalr-client-library).
85+
5486
## Connect to a hub
5587

5688
The following code creates and starts a connection. The hub's name is case insensitive.

0 commit comments

Comments
 (0)