Vanilla HTML
Use staticview components in plain HTML, with or without a build tool.
TypeScript Configuration
Add the component types to your TypeScript configuration:
{ "compilerOptions": { "types": [ // Optional: types what `querySelector` and `createElement` return for each tag // For one component: "@staticview/ui/types/dom/[component-name]" "@staticview/ui/types/dom",
// Optional: declares each component type globally, with no import // For one component: "@staticview/ui/types/global/[component-name]" "@staticview/ui/types/global", ], },}Importing Web Components
With a Build Tool
With a build tool such as Vite, import the component as an ES module to register its tag:
import "@staticview/ui/[component-name]";Without a Build Tool
Staticview CLI
Use the sv add command to copy the minified component files into your project:
npx sv add --type minified --components [component-name] --outdir public/uiLoad the copied file with a module script or a classic script:
<script type="module" src="/ui/[component-name]/[component-name].js"></script>
<!-- Or a classic script --><script src="/ui/[component-name]/[component-name].js"></script>CDN
Load components with no installation from a CDN that mirrors the npm registry.
unpkg
<script type="module" src="https://unpkg.com/@staticview/ui/[component-name]"></script>jsDelivr
<script type="module" src="https://cdn.jsdelivr.net/npm/@staticview/ui/[component-name]"></script>esm.sh (ES modules only)
<script type="module" src="https://esm.sh/@staticview/ui/[component-name]"></script>Note
CDNs suit prototypes and simple pages. In production, copy the components into your project with sv add to control caching and availability yourself.