You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/signalr/javascript-client.md
+45-13Lines changed: 45 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Overview of ASP.NET Core SignalR JavaScript client.
5
5
monikerRange: '>= aspnetcore-2.1'
6
6
ms.author: bradyg
7
7
ms.custom: mvc
8
-
ms.date: 11/12/2019
8
+
ms.date: 04/08/2020
9
9
no-loc: [SignalR]
10
10
uid: signalr/javascript-client
11
11
---
@@ -19,38 +19,70 @@ The ASP.NET Core SignalR JavaScript client library enables developers to call se
19
19
20
20
## Install the SignalR client package
21
21
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**.
23
27
24
28
::: moniker range=">= aspnetcore-3.0"
25
29
26
-
```console
27
-
npm init -y
28
-
npm install @microsoft/signalr
29
-
```
30
+
```bash
31
+
npm init -y
32
+
npm install @microsoft/signalr
33
+
```
30
34
31
35
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.
32
36
33
37
::: moniker-end
34
38
35
39
::: moniker range="< aspnetcore-3.0"
36
40
37
-
```console
38
-
npm init -y
39
-
npm install @aspnet/signalr
40
-
```
41
+
```bash
42
+
npm init -y
43
+
npm install @aspnet/signalr
44
+
```
41
45
42
46
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.
43
47
44
48
::: moniker-end
45
49
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:
49
51
50
52
```html
51
53
<scriptsrc="~/lib/signalr/signalr.js"></script>
52
54
```
53
55
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:
[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
+
54
86
## Connect to a hub
55
87
56
88
The following code creates and starts a connection. The hub's name is case insensitive.
0 commit comments