Libraries (so.lib)
import { Aside } from ‘@astrojs/starlight/components’;
Import a private, versioned JavaScript module — like importing a CDN library, but scoped
to your workspace or account. Access via so.lib(name).
Method
Section titled “Method”// Resolve the pinned-or-latest version of a module by name and dynamic-import it.lib<T = Record<string, unknown>>(name: string): Promise<T>Examples
Section titled “Examples”// Resolve + import by name — version is resolved server-side for this artifact's scope.const { bar, formatCurrency } = await so.lib('charts');bar(document.getElementById('chart'), rows);<!-- Plain HTML, no SDK — import the versioned URL directly. Same-origin, immutable. --><script type="module"> import { bar } from "/lib/your-workspace/charts@1.0.0.js";</script>so.lib('charts') resolves the module in this artifact’s scope — its workspace library
first, then the owner’s personal library — honoring any version pin on the artifact,
otherwise the latest version, then imports same-origin.
Pure modules
Section titled “Pure modules”Library modules are pure: they receive data as arguments and have no ambient SDK,
credentials, or network — like Plotly.newPlot(el, data). The host artifact owns the
data and decides what to pass in.
export const bar = (el, rows, opts) => { /* render only */ };Versioning
Section titled “Versioning”Published versions are immutable (semver). An artifact can pin a module to a
chosen version to stay stable across re-publishes; without a pin, so.lib follows the
latest version. Old pinned import URLs keep resolving forever.
Related
Section titled “Related”- Workspace Library — publishing, scopes, and endpoints