The ASP.NET Core SignalR JavaScript client library enables developers to call server-side hub code.
[View or download sample code](https://github.com/aspnet/Docs/tree/live/aspnetcore/signalr/javascript-client/sample) ([how to download](xref:tutorials/index#how-to-download-a-sample))
## Install the SignalR client package
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**.
```console
npm init -y
npm install @aspnet/signalr
```
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.
## Use the SignalR JavaScript client
Reference the SignalR JavaScript client in the `<script>` element.
```html
<scriptsrc="~/lib/signalr/signalr.js"></script>
```
## Connect to a hub
The following code creates and starts a connection. The hub's name is case insensitive.
Typically, browsers load connections from the same domain as the requested page. However, there are occasions when a connection to another domain is required.
To prevent a malicious site from reading sensitive data from another site, [cross-origin connections](xref:security/cors) are disabled by default. To allow a cross-origin request, enable it in the `Startup` class.
SignalR determines which client method to call by matching the method name and arguments defined in `SendAsync` and `connection.on`.
> [!NOTE]
> As a best practice, call `connection.start` after `connection.on` so your handlers are registered before any messages are received.
## Error handling and logging
Chain a `catch` method to the end of the `connection.start` method to handle client-side errors. Use `console.error` to output errors to the browser's console.
Setup client-side log tracing by passing a logger and type of event to log when the connection is made. Messages are logged with the specified log level and higher. Available log levels are as follows: