ssb-typescript provides comprehensive TypeScript type definitions for the Secure Scuttlebutt (SSB) protocol, enabling developers to build SSB applications with strong type safety. It defines core SSB concepts such as `FeedId`, `MsgId`, `BlobId`, and various message interfaces like `Msg`, `UnboxedMsg`, and `Content` (which is a union of specific content types like `PostContent`, `ContactContent`, `VoteContent`, `BlogContent`, and more). The current stable version is 2.8.0. As a type-only package, its release cadence is typically driven by changes in the underlying SSB protocol or common application patterns, rather than frequent functional updates. Its key differentiator is providing a standardized, community-maintained set of types for the decentralized SSB ecosystem, helping to ensure interoperability and reduce development errors when working with SSB data structures.
npm install ssb-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define common SSB types like `FeedId`, `MsgId`, `PostContent`, and the full `Msg` interface using the provided type definitions.
Review the type definitions in the `ssb-typescript` source or the generated `.d.ts` files after upgrading. Update your application's data structures to match the latest interfaces.
Implement runtime validation or custom type guards for `mentions` arrays. Consider declaring a more specific type if your application has a consistent structure for mentions.
Use type assertions (`as PostContent`), `instanceof` checks (if applicable to your runtime data), or switch statements with `content.type` to narrow down the `Content` type. For `Msg` objects, declare `Msg<SpecificContentType>`.
Keep `ssb-typescript` version synchronized with the versions of other core SSB libraries you are using. Consult the change logs for both `ssb-typescript` and the related SSB libraries during upgrades.
Ensure the package is installed: `npm install ssb-typescript` or `yarn add ssb-typescript`. Verify your `tsconfig.json` includes `node_modules/@types` or has appropriate `typeRoots`.
Add all required properties (e.g., `mentions?: Array<any>;`) to your object, even if they are empty arrays or `undefined`, or ensure optional properties are explicitly set. Check the `PostContent` interface for exact requirements.
While `FeedId` is an alias for `string`, TypeScript might enforce stricter checks depending on context or other utilities. Ensure the string format is correct (e.g., starts with `@` for `FeedId`). If you are certain about the string's correctness, you can use a type assertion: `someString as FeedId`.
Ensure you are constructing a complete `Msg` object (which includes `key`, `value`, `timestamp`) and placing your `PostContent` inside the `value.content` field when a full message is required.
No dependency data recorded yet.