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

@tscircuit/import-snippet

v0.0.5

Published

Dynamically import a tscircuit snippet from the registry. Great for quick scripts that need to import and build a circuit.

Downloads

2,558

Readme

@tscircuit/import-snippet

Dynamically import a tscircuit snippet from the registry. Great for quick scripts that need to import and build a circuit.

[!WARNING] Do not use this inside of snippets, or whenever you're able to just do bun add @tsci/myname.mysnippet, dynamic imports are not nearly as fast, don't have lockfiles, it makes your code async and doesn't give you types!

import { importSnippet } from "@tscircuit/import-snippet"
import { Circuit } from "@tscircuit/core"

const Flashlight = await importSnippet("seveibar/usb-c-flashlight")

const circuit = new Circuit()

circuit.add(<Flashlight />)

In order to import a snippet, often other snippets have to be imported. This import system effectively downloads and bundles dependent snippets to keep the usage as simple as possible.

Usage without React/JSX

Some nodejs folks might not want to have a jsx transpiler, no problem!

import { importSnippet } from "@tscircuit/import-snippet"
import { Circuit, createElement } from "@tscircuit/core"

const Flashlight = await importSnippet("seveibar/usb-c-flashlight")

const circuit = new Circuit()

circuit.add(
  createElement(Flashlight, {
    ledColor: "red",
  })
)

Specifying Types

import { importSnippet } from "@tscircuit/import-snippet"
import { Circuit } from "@tscircuit/core"

const Flashlight = await importSnippet<{
  ledColor: string
}>("seveibar/usb-c-flashlight")

const circuit = new Circuit()

circuit.add(<Flashlight ledColor="red" />)

Acceptable Import URLs

You can specify imports in any of the following ways:

importSnippet("https://tscircuit.com/seveibar/usb-c-flashlight")
importSnippet("seveibar/usb-c-flashlight")
importSnippet("@tsci/seveibar.usb-c-flashlight")
importSnippet("seveibar.usb-c-flashlight")

Alternate registries

You can configure an alternate registry globally with setDefaultRegistry

import { setDefaultRegistry } from "@tscircuit/import-snippet"

setDefaultRegistry("https://myregistry.mycompany.com")

You can also provide the registry as an option to importSnippet

import { importSnippet } from "@tscircuit/import-snippet"

importSnippet("seveibar/usb-c-flashlight", {
  registryUrl: "https://registry-api.tscircuit.com",
})

Injecting Dependencies

You can inject a custom version of @tscircuit/core or other dependencies like @tscircuit/math-utils by providing the "dependencies" property.

If you do not inject dependencies, they will be loaded from the parent environment via "require" (not supported in all environments)

import { importSnippet } from "@tscircuit/import-snippet"
import * as tscircuitCore from "@tscircuit/core"

const MyComponent = await importSnippet("seveibar/usb-c-flashlight", {
  dependencies: {
    "@tscircuit/core": tscircuitCore,
  },
})