{"id":27844,"library":"glitch-javascript-sdk","title":"Glitch JavaScript SDK","description":"Official JavaScript SDK for Glitch, an open-source live community platform for gaming and esports. Version 3.0.6 is current stable. Released as needed; key differentiator is its tight integration with the Glitch backend API. Supports both browser and Node.js environments. Includes TypeScript definitions.","status":"active","version":"3.0.6","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install glitch-javascript-sdk","lang":"bash","label":"npm"},{"cmd":"yarn add glitch-javascript-sdk","lang":"bash","label":"yarn"},{"cmd":"pnpm add glitch-javascript-sdk","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import; CommonJS require is supported but discouraged.","wrong":"const Glitch = require('glitch-javascript-sdk')","symbol":"Glitch","correct":"import Glitch from 'glitch-javascript-sdk'"},{"note":"Config is a nested singleton, not a named export.","wrong":"import { Config } from 'glitch-javascript-sdk'","symbol":"Glitch.config.Config","correct":"import Glitch from 'glitch-javascript-sdk';\nGlitch.config.Config.setBaseUrl(url)"},{"note":"Auth is accessed via Glitch.api.","wrong":"import { Auth } from 'glitch-javascript-sdk'","symbol":"Glitch.api.Auth","correct":"import Glitch from 'glitch-javascript-sdk';\nGlitch.api.Auth.login(email, password)"}],"quickstart":{"code":"import Glitch from 'glitch-javascript-sdk';\n\nGlitch.config.Config.setBaseUrl('https://api.glitch.local/api/', true);\nconst jwt = process.env.JWT ?? '';\nif (jwt) {\n  Glitch.config.Config.setAuthToken(jwt);\n}\n\nGlitch.api.Auth.login('user@example.com', 'password123')\n  .then(() => console.log('Logged in'))\n  .catch(err => console.error(err));\n\n// Use other API endpoints\nGlitch.api.Users.getCurrentUser().then(user => console.log(user));","lang":"typescript","description":"Shows setup, authentication via JWT, login call, and user retrieval."},"warnings":[{"fix":"Use import syntax or enable ESM compat in your bundler (e.g., 'type': 'module' in package.json).","message":"v3.0.0 changed to ESM-only; CommonJS require() will fail without module transformation.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace Glitch.api.Auth.register with Glitch.api.Users.create.","message":"Glitch.api.Auth.register has been deprecated in v3.0.0; use Glitch.api.Users.create","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Explicitly pass true to ensure consistent trailing slash behavior.","message":"Config setBaseUrl second parameter 'addTrailingSlash' defaults to false in v2.x, true in v3.x","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Always call setBaseUrl before setAuthToken.","message":"Setting auth token before base URL may cause requests to fail silently","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use: import Glitch from 'glitch-javascript-sdk';","cause":"Using named imports instead of default import of Glitch object.","error":"Uncaught TypeError: Glitch.config is undefined"},{"fix":"Convert to import syntax or use dynamic import().","cause":"Using require() to import an ESM-only package.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure you import Glitch correctly as default and then call Glitch.config.Config.setBaseUrl.","cause":"Calling Glitch.config.Config.setBaseUrl before initializing Glitch (e.g., using wrong import).","error":"TypeError: Cannot read properties of undefined (reading 'setBaseUrl')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}