{"id":47007,"library":"avro-schema-registry","title":"avro-schema-registry","description":"A JavaScript library (v2.1.5) for Confluent Schema Registry integration, enabling Avro serialization and deserialization of Kafka messages. Requires only avsc as a peer dependency. Caches schemas to reduce network calls. Supports encoding/decoding by schema, ID, or topic. Provides authentication via URL or options object. Updated irregularly; last release in 2023.","status":"active","version":"2.1.5","language":"javascript","source_language":"en","source_url":"git://github.com/bencebalogh/avro-schema-registry","tags":["javascript","kafka","schema","schema-registry"],"install":[{"cmd":"npm install avro-schema-registry","lang":"bash","label":"npm"},{"cmd":"yarn add avro-schema-registry","lang":"bash","label":"yarn"},{"cmd":"pnpm add avro-schema-registry","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Avro schema parsing and serialization","package":"avsc","optional":false}],"imports":[{"note":"The module exports a single function that returns a registry object. Use default import or require().","wrong":"const { registry } = require('avro-schema-registry')","symbol":"default","correct":"import registry from 'avro-schema-registry'"},{"note":"TypeScript users can infer type via ReturnType; there is no explicit named export for the registry type.","wrong":"import { Registry } from 'avro-schema-registry'","symbol":"Registry","correct":"type Registry = ReturnType<typeof import('avro-schema-registry')>"},{"note":"CommonJS require returns the function directly; no .default needed.","wrong":"const registry = require('avro-schema-registry').default('https://host:8081')","symbol":"require()","correct":"const registry = require('avro-schema-registry')('https://host:8081')"}],"quickstart":{"code":"import registry from 'avro-schema-registry';\nimport avsc from 'avsc';\n\nconst reg = registry('https://localhost:8081', { username: 'user', password: 'pass' });\n\nconst schema = { type: 'record', name: 'Test', fields: [{ name: 'field1', type: 'string' }] };\nconst message = { field1: 'hello' };\n\nasync function example() {\n  const encoded = await reg.encodeMessage('test-topic', schema, message);\n  console.log('Encoded:', encoded);\n  const decoded = await reg.decode(encoded);\n  console.log('Decoded:', decoded);\n}\n\nexample().catch(console.error);","lang":"typescript","description":"Shows how to create a registry client, encode an Avro message by topic and schema, then decode it using async/await."},"warnings":[{"fix":"Use const registry = require('avro-schema-registry')('https://url') instead of const registry = require('avro-schema-registry')","message":"require() returns a factory function, not an object with methods. Must call it with URL immediately.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Replace registry.decodeMessage(msg) with registry.decode(msg)","message":"decodeMessage method exists only for backward compatibility; use decode instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use encodeKey(topic, schema, message) for key schemas and encodeMessage(topic, schema, message) for value schemas.","message":"encodeMessage registers the schema under subject `${topic}-value`. For keys, use encodeKey with subject `${topic}-key`. Confusingly, encodeMessage does not handle keys.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use ES import syntax in ESM context, or use dynamic import() in Node environments that support it. For CommonJS, keep using require() as shown.","message":"From v2.0.0, the package is ESM-only but README shows require(). If using native ESM, require() fails.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2023':54 'authent':43 'avro':2,15 'avro-schema-registri':1 'avsc':24 'cach':29 'call':34 'confluent':10 'depend':28 'deseri':18 'enabl':14 'encoding/decoding':36 'id':39 'integr':13 'irregular':50 'javascript':6,55 'kafka':20,56 'last':51 'librari':7 'messag':21 'network':33 'object':48 'option':47 'peer':27 'provid':42 'reduc':32 'registri':4,12,60 'releas':52 'requir':22 'schema':3,11,30,38,57,59 'schema-registri':58 'serial':16 'support':35 'topic':41 'updat':49 'url':45 'v2.1.5':8 'via':44","created_at":"2026-06-07T16:49:16.751457+00:00","updated_at":"2026-06-07T16:49:16.751457+00:00","problems":[{"fix":"const registry = require('avro-schema-registry')('https://your-registry:8081');","cause":"Calling require('avro-schema-registry') without invoking the factory function, so you get the function itself instead of the registry object.","error":"TypeError: registry.decode is not a function"},{"fix":"npm install avsc","cause":"avsc is a peer dependency and must be installed separately.","error":"Error: Cannot find module 'avsc'"},{"fix":"Verify the URL and ensure Schema Registry is running. If using authentication, check credentials.","cause":"Schema Registry URL is incorrect or not reachable.","error":"Error: connect ECONNREFUSED <host>:8081"},{"fix":"Register the schema first using encodeMessage/encodeKey, or provide a valid schema ID.","cause":"The schema ID does not exist in the registry, or the schema was deleted.","error":"Error: Schema not found for id X"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/bencebalogh/avro-schema-registry#readme","github":"git://github.com/bencebalogh/avro-schema-registry","docs":null,"changelog":null,"pypi":null,"npm":"avro-schema-registry","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}