Skip to content

API reference ​

Import components and their TypeScript prop types from pyscript-solid.

PyScriptProvider ​

Loads PyScript 2026.7.3 after its children mount. Matching runtime assets are reused for the page lifetime.

tsx
<PyScriptProvider>
  <PyScript>print("Hello")</PyScript>
</PyScriptProvider>
PropTypeDefault
childrenJSX.Element—
jsSourcestringPyScript CDN core.js
cssSourcestringPyScript CDN core.css

For self-hosting, set both source URLs to matching runtime files. Use one runtime version per page. Sources are read on mount.

Type: PyScriptProviderProperties. The tested version is also exported as PYSCRIPT_VERSION.

PyScript ​

Renders a <script type="py"> element and runs Python when mounted.

tsx
<PyScript target="result">{`from pyscript import display
display(6 * 7)`}</PyScript>
PropTypeDefault / purpose
childrenstringInline Python
srcstringPython file URL; use instead of inline code
type"py" | "mpy""py" (Pyodide); "mpy" for MicroPython
configstring | Record<string, unknown>Object, inline JSON, or JSON/TOML URL
targetstringOutput element ID
workerboolean | stringEnable a worker or name one; omitted by default
terminalboolean | stringEnable terminal output; omitted by default
asyncbooleanEnable async execution; omitted by default

Native script attributes, Solid event handlers, and ref are supported. innerHTML and textContent are excluded; pass Python through children.

Changing props does not rerun Python. Mount a new component to execute again. See worker hosting before using worker.

Type: PyScriptProperties.

PyEditor ​

An editable script that loads its interpreter and runs in a worker when Run is clicked.

tsx
<PyEditor type="mpy-editor">print(6 * 7)</PyEditor>
PropTypeDefault / purpose
childrenstringInitial Python code
srcstringExternal Python file URL
type"py-editor" | "mpy-editor""py-editor"
configstring | Record<string, unknown>Editor configuration
envstringShared environment name

Native script attributes are supported. Editors need their own config; PyConfig does not apply. See worker hosting.

Type: PyEditorProperties. PyRepl and PyReplProperties are deprecated aliases.

PyConfig ​

Shared main-thread configuration. Place one before your scripts, before the runtime first loads.

tsx
<PyConfig>{JSON.stringify({ packages: ["numpy"] })}</PyConfig>
PropTypePurpose
childrenstring (required)JSON or TOML text

Native HTML attributes are supported. Type: PyConfigProperties.

For Python-side APIs, see the PyScript documentation.

Released under the MIT License.