npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

talkjs

v0.26.0

Published

Build a fantastic chat feature in hours instead of months.

Downloads

91,089

Readme

TalkJS JavaScript SDK

This package lets you include TalkJS JS SDK snippet as an npm package.

Please note this package is for the client-side SDK and is intended for browser environments.

We have seporate packages available if you're looking to integrate TalkJS with React Native, and a package with support for Expo. @talkjs/react-native, @talkjs/@expo

What is TalkJS?

TalkJS is a developer friendly chat API with a pre-built UI that is highly customisable. You can build a chat feature in minutes instead of months.

With TalkJS, you can create chat features that boost user engagement, retention, and conversion rate.

Screenshot of TalkJS header

Don't hesitate to let us know if you have any questions about TalkJS.

Getting Started

Use one of the following ways to import the library:

ES6 / TypeScript:

import Talk from "talkjs";

CommonJS:

const Talk = require("talkjs");

Then, follow the guide on our documentation to start using TalkJS in your projects.

Goals

This NPM package has two goals:

  • Make it easier to inject the TalkJS snippet for developers who use front-end build chains such as Webpack or Parcel
  • Provide TypeScript type definitions for the entire SDK, for an easier development experience in editors such as Atom and VS Code. Some editors (eg VS Code) will use these for autocompletion if your application is not written in TypeScript:

Visual Studio Code autocomplete screenshot

Note that even if you use this package, the core TalkJS library is loaded on-the-fly from our CDN. It simply injects a small code snippet which does that asynchronously, without delaying the rest of your application.

Examples, guides & tutorials

You can check out usage examples for this package and TalkJS in general, check out our examples repository. Our resources section on the site covers a wide array of tutorials and Frequently asked Questions.

There are multiple quickstart guides available:

Usage from Node.js

This package is currently frontend only. You can import this package in Node.js, but it will only work from code that is called in a browser. If you use a framework that runs the same code on Node.js and in the browser (eg Next.js), then make sure you only call TalkJS functions inside the browser. See our Next.js example for more info.

On forward compatibility

We take API compatibility extremely seriously. We spend a lot of effort to ensure that customer code that used to work, keeps working, even when we iterate on the SDK design. We may at times deprecate methods or fields, but we will not remove them. If something that used to work stops working, then that's a bug. Please report it and we'll fix it asap.

A note for TypeScript users

We do not consider a change in the type definitions a breaking change that warrants a major version release.

None of this should ever affect you unless you manually update the NPM package to a newer version using a command like npm install --save talkjs@latest at a later time. And even then, nothing will break at runtime because we provide full forward compatibility of the JavaScript API.

In other words, code like the following should always keep working and compiling, even if you update this package:

import Talk from "talkjs";
const session = new Talk.Session(..);
const inbox = session.createInbox(..);

But code using TypeScript types might cause compile errors when you update the package to a later version, because we may rename the Talk.Inbox type:

import Talk from "talkjs";
function createInbox(): Talk.Inbox { // <-- this line is the culprit
    const session = new Talk.Session(..);
    return session.createInbox(..);
}

Similarly, we may at any time remove deprecated methods, fields, classes and interfaces from the TypeScript definitions (but not from the JavaScript SDK).

Changelog

Note: These are only the changes that have an effect on the JS level. TalkJS gets many improvements and fixes all the time. Consider subscribing to our changelog if you want to stay updated.

0.26.0

  • Added customEmojis setting to createChatbox, createInbox and createPopup.

0.25.0

0.24.0

0.23.1

  • Fixed ConversationSnapshot.createdAt and ConversationSnapshot.lastMessageAt to be number instead of Date.

0.23.0

0.22.0

0.21.0

0.20.0

0.19.0

0.18.0

  • Deprecated ConversationSelectedEvent.others and SelectConversationEvent.others in favour of .participants due to others having strange behaviour when in a conversation by yourself.
  • Calling .select on a UI now returns a promise that is resolved when the new conversation is selected

0.17.0

0.16.6

0.16.5

0.16.4

0.16.3

0.16.2

  • Added session.onBrowserPermissionNeeded. This event is triggered when the browser is about to prompt the user for a certain permission. You can use this to show more information to the user before the browser prompt.
  • Added session.onBrowserPermissionDenied. This event is triggered when the user or the browser denies a certain permission. You can use this to show an explanation of how to re-enable the permission if they change their mind.

0.16.1

0.16.0

0.15.9

0.15.8

  • Updated README.md (Forgot to add the changelog entry for 0.15.7)

0.15.7

0.15.6

0.15.5

0.15.4

0.15.3

0.15.2

  • The way to attach event handlers has changed. Methods like on("focus", handler) to register events on the Chatbox, Popup or Inbox are now deprecated. Instead, we recommend that you use the equivalent methods like onFocus instead. The same thing goes for event handlers on Session and Unreads objects.
  • Similarly the off method to remove event listeners has been deprecated too. New event handler methods return a Subscription object, which has an unsubscribe() method to stop listening for events.
  • Add onCustomMessageAction event

0.15.1

0.15.0

  • Add Guest access that enables hundreds of users in the chat at the same time.

0.14.5

0.14.4

0.14.3

0.14.2

0.14.1

0.14.0

  • Added the ability to search within a conversation - available on the Premium plan and above.
  • Changed the default for the popup's 'launcher' option to default to 'always' instead of 'close-only'.
  • Changed the default for the popup's 'keepOpen' option to default to 'false' instead of 'true'.

0.13.1

  • Add option to show/hide the mobile back button for the Inbox UI.

0.13.0

0.12.0

  • Simplify "no chats" inbox layout; take background and borders from theme .panel setting.

0.11.0

0.10.3

0.10.2

  • Make the SDK compatible with typescript 2.3 and older browsers.

0.10.1

  • Fix circular type reference.

0.10.0

  • Fix bug that would not let TypeScript users do import Talk from "talkjs" in some situations. Note that before this change, in some setups you could actually do import * as Talk to get around this. That stops working now.

0.9.1

  • Added Session#destroy that destroys the current connection to the TalkJS server.

0.9.0

  • Removed exception when talkjs is required or imported in non-browser environments (eg Node.js). Using the package outside the browser still throws an exception, but just importing it doesn't anymore.

0.8.1

  • Exposed Talk.Error.
  • Added MessageFilter.
  • Added missing custom field to the Message interface.
  • Added the ability to override message contents and custom field via the JSSDK.

0.8.0

  • Added explicit support for ESNext modules, to make this package work with eg Rollup.
  • Typings now expose the custom field on the Message interface
  • Fixed TypeScript exports: types were exported as separate named exports, even though the TalkJS SDK actually default-exports a single Talk object. To update existing an TypeScript codebase to use the new types, change all occurrences of import * as Talk from "talkjs" to import Talk from "talkjs". If you use CommonJS (require) then no changes are needed.

0.7.0

0.6.1

0.6.0

  • Converted some classes to interfaces (eg Inbox is now an interface).
  • Exported all interfaces that the SDK exposes. For example, Session.getOrCreateConversation returns a ConversationBuilder interface, which you can now use in TypeScript code like function updateConversation(conversation: Talk.ConversationBuilder) {..}.

0.5.0

  • Exported core interfaces in the TypeScript type definitions: Chatbox, Conversation, ConversationBuilder, Inbox, Popup.
  • Began tracking a changelog :-)