New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@jamsocket/javascript

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jamsocket/javascript

JavaScript/TypeScript, and React libraries for interacting with session backends and the Jamsocket platform.

Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
6
-45.45%
Maintainers
3
Weekly downloads
 
Created
Source

@jamsocket/javascript

JavaScript/TypeScript, and React libraries for interacting with session backends and the Jamsocket platform.

npm install @jamsocket/javascript
import { init } from '@jamsocket/javascript/server'

const spawnBackend = init({
  account: '[YOUR ACCOUNT]',
  token: '[YOUR TOKEN]',
  service: '[YOUR SERVICE]',
})

// this spawns a backend via the Jamsocket API and returns a URL you can
// use to connect to your backend - or pass the spawnResult to a SessionBackendProvider
// and use Jamsocket's React hooks to interact with your session backend
const spawnResult = await spawnBackend()

// you may also pass in any of the following spawn options
// learn more about spawn options at https://docs.jamsocket.com/api-docs/#spawn-a-service
const spawnResult = await spawnBackend({
  lock: 'my-lock',
  tag: 'my-tag',
  env: { MY_ENV_VAR: 'foo' },
  gracePeriodSeconds: 300,
  requireBearerToken: true,
})
import { SessionBackendProvider } from '@jamsocket/javascript/react'

// wrap a component in a SessionBackendProvider so the child components
// can use Jamsocket hooks for interacting with the session backend (like useEventListener, useSend, etc)
<SessionBackendProvider spawnResult={spawnResult}>
  <MyComponent />
</SessionBackendProvider>
import { useEventListener, useReady, useSend } from '@jamsocket/javascript/react'

function MyComponent() {
  const sendEvent = useSend()
  function onMouseMove() {
    // send an event message to your session backend over websockets
    sendEvent('some-event', someValue)
  }

  useEventListener('another-event', (args) => {
    // do something when receiving an event message from your session backend...
  })
}

FAQs

Package last updated on 19 Jan 2024

Did you know?

Socket

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.

Install

Related posts