44
55[ ![ NPM Version] ( https://img.shields.io/npm/v/@dschz/solid-create-script.svg?style=for-the-badge )] ( https://www.npmjs.com/package/@dschz/solid-create-script )
66[ ![ Build Status] ( https://img.shields.io/github/actions/workflow/status/dsnchz/solid-create-script/ci.yaml?branch=main&logo=github&style=for-the-badge )] ( https://github.com/dsnchz/solid-create-script/actions/workflows/ci.yaml )
7- [ ![ bun] ( https://img.shields.io/badge/maintained%20with-bun-cc00ff.svg?style=for-the-badge&logo=bun )] ( https://bun.sh/ )
7+ [ ![ TypeScript] ( https://img.shields.io/badge/TypeScript-supported-blue?style=for-the-badge&logo=typescript )] ( https://www.typescriptlang.org/ )
8+ [ ![ SSR Compatible] ( https://img.shields.io/badge/SSR-compatible-brightgreen?style=for-the-badge )] ( # )
89
910# @dschz/solid-create-script
1011
11- > SolidJS hook to declaratively load external scripts, built on top of [ ` @dschz/load-script ` ] ( https://www.npmjs.com/package/@dschz/load-script ) .
12+ > SolidJS hook to load external scripts -- built on top of [ ` @dschz/load-script ` ] ( https://www.npmjs.com/package/@dschz/load-script ) .
1213
1314## ✅ Features
1415
2021
2122``` bash
2223npm install solid-js @dschz/load-script @dschz/solid-create-script
23-
2424pnpm install solid-js @dschz/load-script @dschz/solid-create-script
25-
2625yarn install solid-js @dschz/load-script @dschz/solid-create-script
27-
2826bun install solid-js @dschz/load-script @dschz/solid-create-script
2927```
3028
@@ -37,15 +35,15 @@ bun install solid-js @dschz/load-script @dschz/solid-create-script
3735
3836### ` createScript(src, options?, container?) `
3937
40- Wraps ` loadScript ` in a ` createResource() ` to enable declarative async tracking inside SolidJS .
38+ Loads an external script dynamically and returns a ` Resource<HTMLScriptElement> ` .
4139
4240#### Parameters:
4341
44- - ` src ` _ (string) _ : the script source to download
45- - ` options ` _ (LoadScriptOptions) _ : standard script attributes (e.g. ` async ` , ` type ` , ` nonce ` , etc.)
46- - ` container ` _ (HTMLElement) _ : DOM node to append the script to (defaults to ` document.head ` )
47-
48- Returns a Solid ` Resource<HTMLScriptElement> ` .
42+ | Name | Type | Description |
43+ | ----------- | ------------------- | ----------------------------------------------------------------- |
44+ | ` src ` | ` string ` | Script URL (required) |
45+ | ` options ` | ` LoadScriptOptions ` | ` loadScript ` options (e.g. ` async ` , ` type ` ) |
46+ | ` container ` | ` HTMLElement ` | HTML element to append ` <script /> ` to (default: ` document.head ` ) |
4947
5048## 🧪 Example
5149
@@ -70,7 +68,7 @@ const CustomComponent = () => {
7068
7169- Scripts are cached by ` src ` unless ` innerHTML ` or ` textContent ` is used
7270- Scripts are not automatically removed on cleanup/unmount
73- - Designed to be simple and safe to use inside SolidJS components
71+ - Designed to be simple and safe to use inside SolidJS components (in SSR and non-SSR environments)
7472
7573## 💬 Feedback & Contributions
7674
0 commit comments