API docs
Search docs
Guides, operations and types

Cosmetics SDK

Show JilTV paints, badges, avatar frames and profile banners with one package. It loads the catalog, finds out what a user wears in the channel you show, renders paints exactly like jiltv.app and keeps everything up to date live. No key needed.

Install

Terminal
npm install @jiltv/cosmetics

Or without a build step, straight from the CDN:

HTML
<script type="module" src="https://cdn.jsdelivr.net/npm/@jiltv/cosmetics@1/dist/cdn.js"></script>

Around 20 KB gzipped, no dependencies. Works in every current browser. The data parts (look(), paintCss()) also run on servers.

HTML elements

The quickest way: put the elements where names and avatars go. They resolve the user, paint themselves and stay current.

HTML
<script type="module" src="https://cdn.jsdelivr.net/npm/@jiltv/cosmetics@1/dist/cdn.js"></script>

<!-- Name with paint, Twitch color underneath, badge in front -->
<jiltv-name login="jilence" color="#ff4500" badge>Jilence</jiltv-name>

<!-- Profile picture with frame; a Twitch user ID works everywhere instead of login -->
<jiltv-avatar twitch-id="438697907" src="https://…/avatar.png" size="64"></jiltv-avatar>

<!-- Just the badge -->
<jiltv-badge login="jilence"></jiltv-badge>
ElementAttributes
<jiltv-name>login or twitch-id, color (Twitch name color), badge (badge in front), channel. The text inside is the name.
<jiltv-avatar>login or twitch-id, src (profile picture), size (px, default 40), alt, channel. Or put your own <img> inside instead of src.
<jiltv-badge>login or twitch-id, size (px, default 18), channel

With a bundler, import the elements once:

JavaScript
import '@jiltv/cosmetics/elements';
import { configure } from '@jiltv/cosmetics/elements';

configure({ channel: 'streamer' }); // optional: looks for this channel

JavaScript

name() and avatar() bind an element to a user: the SDK resolves the look, draws it and repaints it when the user changes their look or you switch channels.

JavaScript
import { createJilTV } from '@jiltv/cosmetics';

const jiltv = createJilTV({ channel: 'streamer' });

// Paints the element (it should hold only the name) and keeps it current.
jiltv.name(nameEl, 'jilence', { color: '#ff4500', badge: true });

// Frame around the <img> inside avatarBox, at 120 %, centered.
jiltv.avatar(avatarBox, { twitchId: '438697907' });
  • The Twitch name color goes in color. Transparent parts of a paint show it, like in Twitch chat. In chat it is the color tag of the IRC message; leave it out and the surrounding text color shows.
  • Contrast and time of day need nothing from you. Paints with a contrast base pick black, white or their own pair from the name color, and paints with looks by time of day switch at the viewer's local phase times. Both since version 1.1.
  • The name element should hold only the name: no badges, no colon, no padding.
  • Users are a Twitch login ('jilence') or { twitchId: '438697907' }. Logins are faster: an ID costs one extra request the first time.

Just the data

For your own rendering, ask for the look and use the helpers:

JavaScript
const look = await jiltv.look({ twitchId: '438697907' });
// {
//   paint:      { id, name, version, rarity, designers, fallback } | null,
//   badge:      { id, name, url, size, ... } | null,
//   decoration: { id, name, url, size, ... } | null,
//   banner:     { id, card, cardStill, full, fullStill } | null
// }

jiltv.paint(el, look.paint, { color: '#ff4500' }); // draw it yourself
jiltv.decorate(avatarBox, look.decoration);
if (look.badge) nameEl.before(jiltv.badgeImage(look.badge));
if (look.banner) header.style.backgroundImage = `url(${look.banner.card})`;

jiltv.all() lists every published paint, badge and decoration, e.g. for a gallery.

Per channel

JavaScript
const jiltv = createJilTV({ channel: 'streamer' });

// The viewer opens another channel: every bound name and frame updates.
jiltv.setChannel('otherstreamer');

// One element in a different channel than the rest:
jiltv.name(el, 'alice', { channel: 'thirdchannel' });

Live updates

While elements are bound, the SDK keeps one WebSocket open and repaints a user's elements as soon as they change their look, including looks for single channels. It reconnects by itself and closes when nothing is bound. Pass live: false to turn it off.

JavaScript
// Bound elements repaint on their own. For your own UI:
const stop = jiltv.onChange(async (login) => {
  const look = await jiltv.look(login);
  // update what you show for this user
});

// Elements you removed from the page are dropped automatically,
// or stop updating one yourself:
jiltv.unbind(el);

Frameworks

Create one client per app and bind elements when they mount:

React
import { useEffect, useRef } from 'react';
import { createJilTV } from '@jiltv/cosmetics';

const jiltv = createJilTV(); // one per app

export function Name({ login, color, children }) {
  const ref = useRef(null);
  useEffect(() => {
    jiltv.name(ref.current, login, { color });
    return () => jiltv.unbind(ref.current);
  }, [login, color]);
  return <span ref={ref}>{children}</span>;
}
Svelte
<script>
  import { createJilTV } from '@jiltv/cosmetics';
  const jiltv = createJilTV();

  let { login, color, children } = $props();

  /** @param {HTMLElement} el */
  function painted(el) {
    $effect(() => {
      jiltv.name(el, login, { color });
      return () => jiltv.unbind(el);
    });
  }
</script>

<span use:painted>{@render children()}</span>

Server-side rendering

JavaScript
// Server: CSS for a paint on your own selector, so names never flash unpainted.
const jiltv = createJilTV({ live: false });
const look = await jiltv.look('jilence');
const css = look.paint && jiltv.paintCss(look.paint, '.name-jilence');
// <style>${css}</style> <span class="name-jilence" style="color:#ff4500">Jilence</span>

Options

OptionDefaultMeaning
channelnoneTwitch login of the channel you show
livetrue in browsersFollow changes over a WebSocket
motion'animated''static' freezes paints on their first frame. Reduced motion is respected either way.
importantfalseWin against other scripts that style names (e.g. other chat extensions)
apihttps://api.jiltv.appAPI base URL
fetchglobal fetchCustom fetch, e.g. on servers
MethodDoes
name(el, user, { color, badge, channel })Paints a name and keeps it current
avatar(box, user, { channel })Frame around the picture in box, kept current
unbind(el)Stops updating an element
look(user, channel?)What a user wears
paint(el, paint, { color })Draws a paint on an element once
paintCss(paint, selector)CSS for a paint, for servers and shadow roots
decorate(box, decoration)Draws a frame once
badgeImage(badge, size?)An <img> for a badge
setChannel(login), setMotion(motion)Change options; bound elements update
onChange(fn)Called with a login when that user's look changes
ready(), all()Preload the catalog, list every cosmetic
destroy()Removes the styles and closes the connection

Without the SDK, for native apps or other languages: Render paints and Show what chatters wear describe the same steps by hand.

License

The SDK is free to use, also in paid apps, for one purpose: showing JilTV cosmetics of JilTV users. In short:

  • Use it unmodified in your own websites, apps and services; bundling it into your app is fine.
  • Show cosmetics only on or next to the user who wears them.
  • Don't use it to render, design or sell other cosmetics, or to build a competing cosmetics service.
  • Don't modify, redistribute on its own, or reverse engineer it.

The full text ships with the package as LICENSE.

Search
Find emotes or users, or jump to a page