Skip to content

socket.io-client on the browser #5383

Open

Description

@sakgoyal

Describe the bug
I want to be able to import the client version without having to use a bundler / using the serveClient option on the server. Can you just provide an ES2020 module that I can just directly import?

This is when I use the npm package instead of a http import (so I get typescript support).

Expected behavior

// client.ts (bundled for browser)
import { io } from 'socket.io-client/browser';
// ...

What I am currently doing
copying the esm output to a local directory

// client.ts (bundled for browser)
// @ts-types="npm:socket.io-client"
import { io } from './socket.io.esm.min.js';
deno bundle client.ts -o client.js

Platform:

  • Runtime: Deno 2.4.5
  • OS: Windows 10

Activity

  1. added
    to triageWaiting to be triaged by a member of the team
    on Aug 28, 2025
  2. sakgoyal commented on Aug 28, 2025

    @sakgoyal
    Author

    maybe by adding a new tsconfig like tsconfig.esm.json called tsconfig.browser.esm.json

    but make it ES2020 and use bundler, instead of node module resolution

  3. added
    enhancementNew feature or request
    and removed
    to triageWaiting to be triaged by a member of the team
    on May 29, 2026
  4. darrachequesne commented on Sep 29, 2026

    @darrachequesne
    Member

    I think exposing the browser ESM bundle through a dedicated subpath makes sense. We could add a socket.io-client/browser export pointing to dist/socket.io.esm.min.js with the existing ESM declarations, so Deno users can import io directly from the npm package without copying the generated file locally:

    {
      "exports": {
        "./browser": {
          "types": "./build/esm/index.d.ts",
          "default": "./dist/socket.io.esm.min.js"
        }
        // ...
      }
    }

    and then import { io } from 'socket.io-client/browser';

    What do you think?

  5. sakgoyal commented on Sep 29, 2026

    @sakgoyal
    Author

    yep makes sense. that should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions