npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@microfox/linkedin-share-sdk

v1.1.0

Published

LinkedIn SDK for Microfox - A robust TypeScript SDK for LinkedIn Share API integration

Readme

@microfox/linkedin-share-sdk

A robust TypeScript SDK for sharing content on LinkedIn with built-in Zod validation.

Features

  • 📘 Full TypeScript support with type definitions
  • 🛡️ Runtime validation with Zod schemas
  • 📱 Rich content sharing capabilities:
    • Text posts
    • Articles
    • Images
    • Videos
    • Documents
  • 🔒 Multiple visibility options (Public, Connections, Logged-in)
  • ⚠️ Comprehensive error handling with descriptive messages
  • 🎯 Simple, intuitive API

Installation

npm install @microfox/linkedin-share-sdk
# or
yarn add @microfox/linkedin-share-sdk
# or
pnpm add @microfox/linkedin-share-sdk

Usage

Basic Setup

import { LinkedinShareSdk } from '@microfox/linkedin-share-sdk';

const share = new LinkedinShareSdk('your_access_token');

Share Content

Simple Text Post

await share.post({
  text: 'Hello LinkedIn!',
  visibility: 'PUBLIC', // Default visibility
});

Share an Article

await share.post({
  text: 'Check out this article!',
  mediaCategory: 'ARTICLE',
  media: [
    {
      url: 'https://example.com/article',
      title: 'Amazing Article',
      description: 'Must-read content',
    },
  ],
});

Share an Image

await share.post({
  text: 'Check out this image!',
  mediaCategory: 'IMAGE',
  media: [
    {
      url: 'https://example.com/image.jpg',
      title: 'My Image',
      thumbnailUrl: 'https://example.com/thumbnail.jpg',
    },
  ],
});

Share with Custom Visibility

await share.post({
  text: 'For my connections only',
  visibility: 'CONNECTIONS',
});

Create a Draft Post

await share.post({
  text: 'Draft post',
  isDraft: true,
});

Validation and Error Handling

The SDK uses Zod for comprehensive validation at multiple levels:

  1. Input Validation: All post options are validated before processing
  2. Content Validation: The constructed share content is validated before sending to LinkedIn
  3. Response Validation: LinkedIn's response is validated to ensure correct format

Handling Validation Errors

import { z } from 'zod';
import { LinkedinShareSdk } from '@microfox/linkedin-share-sdk';

const share = new LinkedinShareSdk('your_access_token');

try {
  await share.post({
    text: 'Hello LinkedIn!',
    mediaCategory: 'INVALID_CATEGORY', // This will trigger a validation error
  });
} catch (error) {
  if (error instanceof z.ZodError) {
    // Handle validation errors
    console.error('Validation failed:', error.errors);
    // error.errors will contain detailed information about what went wrong
    // [{
    //   code: 'invalid_enum_value',
    //   path: ['mediaCategory'],
    //   message: "Invalid enum value. Expected 'NONE' | 'ARTICLE' | 'IMAGE' | 'VIDEO' | 'DOCUMENT'"
    // }]
  } else {
    // Handle other errors (network, LinkedIn API, etc.)
    console.error('Share failed:', error.message);
  }
}

Available Schemas

The SDK exports its Zod schemas if you need to validate data before calling the API:

import {
  postOptionsSchema,
  mediaContentSchema,
  mediaCategorySchema,
  visibilitySchema,
} from '@microfox/linkedin-share-sdk';

// Validate post options
const validOptions = postOptionsSchema.parse({
  text: 'Hello',
  mediaCategory: 'IMAGE',
});

// Validate media content
const validMedia = mediaContentSchema.parse({
  url: 'https://example.com/image.jpg',
  title: 'My Image',
});

Types

import type {
  LinkedInPostOptions,
  LinkedInShareContent,
  LinkedInShareResponse,
  LinkedInMediaContent,
  LinkedInVisibility,
  MediaCategory,
} from '@microfox/linkedin-share-sdk';

Media Categories

type MediaCategory = 'NONE' | 'ARTICLE' | 'IMAGE' | 'VIDEO' | 'DOCUMENT';

Visibility Options

type LinkedInVisibility = 'PUBLIC' | 'CONNECTIONS' | 'LOGGED_IN';

Post Options

interface LinkedInPostOptions {
  text: string;
  visibility?: LinkedInVisibility;
  mediaCategory?: MediaCategory;
  media?: LinkedInMediaContent[];
  isDraft?: boolean;
}

Media Content

interface LinkedInMediaContent {
  url?: string;
  title?: string;
  description?: string;
  thumbnailUrl?: string;
}

License

MIT