
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
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
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.
Don't hesitate to let us know if you have any questions about TalkJS.
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.
This NPM package has two goals:
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.
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:
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.
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.
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).
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.
ConversationSnapshot.lastMessageAt
. Use ConversationSnapshot.lastMessage.createdAt
instead.FileToken
that you can use in SendMessageParams
or EditMessageParams
.ConversationRef.send
to send a message by specifying its content directly. This allows you to send text messages with manually-specified formatting, in addition to file attachments and locations.MessageRef.edit
MessageSnapshot.referencedMessage: ReferencedMessageSnapshot
)MessageSubscription
, and MessageActiveState
.createChatbox
, createInbox
and createPopup
.ConversationSnapshot.createdAt
and ConversationSnapshot.lastMessageAt
to be number
instead of Date
.get(): ConversationSnapshot
.messageId
to Inbox.selectConversationSelectedEvent.others
and SelectConversationEvent.others
in favour of .participants
due to others
having strange behaviour when in a conversation by yourself..select
on a UI now returns a promise that is resolved when the new conversation is selectedConversationListHeader
and ConversationListItem
theme components. As a result, ConversationActionEvent.conversation
can now be null
.action
parameter in onCustomConversationAction and onCustomMessageAction optional, so that it can trigger an event for any action.theme
option passed to session.createChatbox
and other methods to create a widget now optionally lets you pass a custom
property to pass data to theme. Read our documentation on passing data to themes for more info.lastMessageTs
and subject
to ConversationPredicate.presence
to ChatboxOptions, InboxOptions and PopupOptions.sendFile
and sendLocation
methods to Chatbox, Inbox and PopupMentionsOnly
Notify option to setParticipant.KeyupEvent
to KeyEvent (the old KeyupEvent
remains exported as an alias)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.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.theme
option to createInbox, createChatbox and createPopup which lets you override which Custom Theme is shown.session.on("desktopNotificationClicked")
which lets you handle user clicks on browser notifications.undefined
and null
as paremeters to inbox.select, chatbox.select, popup.select and to session.createInbox, session.createChatbox, session.createPopup..panel
setting.createInbox
and friends.createInbox
and friends.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.Session#destroy
that destroys the current connection to the TalkJS server.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.Talk.Error
.MessageFilter
.custom
field to the Message
interface.custom
field on the Message
interfaceimport * as Talk from "talkjs"
to import Talk from "talkjs"
. If you use CommonJS (require
) then no changes are needed.chatBox.messageField.setText(...)
User.configuration
to User.role
(with full backward compatibility, i.e. configuration
is now a deprecated alias for role
.Inbox
is now an interface).Session.getOrCreateConversation
returns a ConversationBuilder
interface, which you can now use in TypeScript code like function updateConversation(conversation: Talk.ConversationBuilder) {..}
.FAQs
Build the perfect messaging experience in 10 minutes.
The npm package talkjs receives a total of 11,851 weekly downloads. As such, talkjs popularity was classified as popular.
We found that talkjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.