Skip to content

Integrate tawk.to into react application

License

Notifications You must be signed in to change notification settings

zaarheed/next-tawkto

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-tawkto

A simple wrapper around tawk.to JS API to help integrate chat into any application that is based on the react framework.

Forked from Steve-Junior/tawkto-react and added support for React v18 since it was stopping me from upgrading to Next.js v13

Installation

npm install next-tawkto --save

Usage

This package is simple react wrapper around the tawk.to JS API. Explore the Tawk JS API as you wish.

Please consider migrating to the latest version and fetch the propertyId and tawkId from your account

Screenshot

class component

import TawkTo from "next-tawkto"

componentDidMount()
{
    var tawk = new TawkTo(propertyId, tawkId)

    tawk.hideWidget()
}

functional component

import TawkTo from "next-tawkto"

useEffect(() => {
    
    var tawk = new TawkTo(propertyId, tawkId)

    tawk.onStatusChange((status) => 
    {
        // console.log(status)
    })

}, [])

my preferred implementation in Next.js hosted on Vercel

useEffect(() => {
    if (!window) return;

    if (process.env.NEXT_PUBLIC_ENVIRONMENT !== "live") return;

    new tawkTo(propertyId, tawkId);
}, []);

License

MIT

Authors

  • Steve Junior
  • Zahid Mahmood

About

Integrate tawk.to into react application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%