Solid-JS
The intention here will be to provide an overview of all bound functions and types from solid-js.
Depending on the level of motivation when I write this, and until I complete my
SolidBase.DocGen, the level of detail varies. Best resource is to visit thesolid-jsdocs.In cases where we have 'unique' calls/signatures, that will be documented here and/or in the 'API Differences' section.
When drawing up a type signature, if referencing a component that takes children,
the type will interface HtmlContainer. Otherwise interface HtmlElement.
Optional constructor properties/parameters are val declarations. An interface object
uses member declarations.
Components which only take a specific signature or type of children will declare
a val children.
Methods will use let to provide syntax highlighting. To provide overloads, they
are actually static members on a type marked with [<AutoOpen>].
See something missing?
Please submit an issue and we will update the bindings within a day or two.
Signal
type Signal<'T> = Accessor<'T> * Setter<'T>Accessor
type Accessor<'T> = unit -> 'TSetter
Calling the setter updates the signal, triggering dependents to rerun (if the value actually changed).
type Setter<'T> = 'T -> unitYou can optionally .Invoke a setter to pass it a handler, which will be expected
to provide the new value from the previous value.
There is an overload which resembles the normal behaviour too.
[<Extension; Erase>]static member inline Invoke(setter: Setter<'T>, handler: 'T -> 'T): unit[<Extension; Erase>]static member inline Invoke(setter: Setter<'T>, value: 'T): unitTo access the new value that is set, you can use .InvokeAndGet.
[<Extension; Erase>]static member inline InvokeAndGet(setter: Setter<'T>, handler: 'T -> 'T): 'T[<Extension; Erase>]static member inline InvokeAndGet(setter: Setter<'T>, value: 'T): 'TContext
type Context<'T> = 'T -> ContextProvidertype ContextProvider = inherit HtmlContainerCreated by passing a JS.Pojo (recommended) to a createContext call as a type arg or value.
The default is set by calling the given Context function with the value.
The plugin transpiles the
'T -> ContextProviderfunction call with the identifier suffixed by.Provideras per the solid-js spec
Dynamic
type Dynamic<'T>() = interface HtmlElementval component': TagValueval componentAsString: stringOverload to component' accepting a string for native components.
For
type For<'T>() = interface HtmlElementval each: 'T[]The array of items that are accessible within the child function.
val fallback: HtmlElementFallback element to render while the list is loading.
val children: (item: 'T) -> (index: Accessor<int>) -> #HtmlElementSimilar to passing an array to an Array.mapi call. The array passed to
each has each member acted on by the given function.
The parameters of the lambda are the item of the array, and a reactive getter for
theindex of that item.
Use
Indexfor the item to be a reactive getter instead.
Index
type Index<'T>() = interface HtmlElementval each: 'T[]val fallback: HtmlElementval children: (item: Accessor<'T>) -> (index: int) -> #HtmlElementNoHydration
type NoHydration() = interface FragmentNodeShow
type Show() = interface HtmlContainerval when': boolval fallback: HtmlElementval keyed: boolAlternate typed syntax for using a render function:
type Show<'T>() = interface HtmlElement interface ChildLambdaProvider<'T>val when': 'TMatch
type Match() = interface HtmlContainerval when': boolSwitch
type Switch() = interface HtmlElementval children: MatchSuspense
type Suspense() = interface HtmlContainerval fallback: HtmlElementSuspenseList
type SuspenseList() = interface HtmlContainermodule SuspenseList = [<StringEnum>] type RevealOrder = | Forwards | Backwards | Together
val revealOrder: SuspenseList.RevealOrdermodule SuspenseList = [<StringEnum>] type Tail = | Collapsed | Hidden
val tail: SuspenseList.Tailval fallback: HtmlElementPortal
type Portal() = interface HtmlContainerval mount: Elementval useShadow: boolval isSVG: boolErrorBoundary
type ErrorBoundary() = interface HtmlContainermodule ErrorBoundary = type Fallback = delegate of err: obj * reset: (unit -> unit) -> HtmlElementval fallback: ErrorBoundary.Fallbackval plainFallback: HtmlElementOverload for fallback which accepts a simple HtmlElement when you don't need to introspect the error or reset
the boundary.
Functions
children
let children(value: unit -> #HtmlElement): Accessor<#HtmlElement>mergeProps
let mergeProps([<ParamList>] values: 'T[]): 'TTypical usage of this is abstracted away for you when making components
using the [<SolidTypeComponent>] attribute.
splitProps
let splitProps( o: 'T, properties: string[], ?otherProperties: string[] ): 'T * 'TTypical usage of this is abstracted away for you when making components
using the [<SolidTypeComponent>] attribute.
render
let render( code: unit -> #HtmlElement, element: #Element ): unitrenderToString
let renderToString(fn: unit -> #HtmlElement): stringcreateSignal
let createSignal( value: 'T, ?equals: oldVal: 'T -> newVal: 'T -> bool, ?name: string, ?``internal``: bool ): Signal<'T>To store a function, you will have to keep in mind that subsequent setting of the signal will have to be in function form (except during initial assignment):
let myFunc () = console.log("myFunc")let accessor,setter = createSignal(unbox<unit -> (unit -> unit)> myFunc)let myNewFunc () = console.log("newFunc")setter (fun () -> myNewFunc)createMemo
let createMemo(value: unit -> 'T): Accessor<'T>let createMemo(value: 'T -> 'T, initialValue: 'T): Accessor<'T>Experimental CE
open Partas.Solid.Experimentalmemo { ... }createEffect
let createEffect(effect: unit -> unit): unitExperimental CE
open Partas.Solid.Experimentaleffect { ... }let createEffect( effect: 'T -> 'T, initialValue: 'T ): unitcreateContext
let createContext<'T>(?value: 'T): Context<'T>useContext
let useContext(context: Context<'T>): 'TcreateResource
let createResource( fetcher: unit -> JS.Promise<'T>, ?initialValue: 'T // Using Async<'T> will have Async.StartAsPromise injected ) = SolidResource<'T> * SolidResourceManager<'T>// Fetcher only called when 'U is Somelet createResource( source: unit -> 'U option, fetcher: 'U -> JS.Promise<'T>, ?initialValue: 'T // Using Async<'T> will have Async.StartAsPromise injected ) = SolidResource<'T> * SolidResourceManager<'T>let createResource( ?source: unit -> 'U option, fetcher: ResourceFetcher<'U option, 'T>, ?initialValue: 'T, ?name: string, ?deferStream: bool, ?onHydrated: (unit -> unit), ?ssrLoadFrom: string, ?storage: Signal<'T> ): SolidResource<'T> * SolidResourceManager<'T>SolidResource
type SolidResource<'T> = interfacemember current: 'Tmember state: SolidResourceStatemember loading: boolmember error: exn optionmember latest: 'TUnlike current, it keeps the latest value while re-loading.
Will be undefined until first value has been loaded.
SolidResourceManager
type SolidResourceManager<'T> = interfacemember mutate: 'T -> 'Tmember refetch: unit -> JS.Promise<'T>Can alternatively pass an argument to refetch which can be accessed by the
handler if using the ResourceFetcher overload. See below.
[<Extension; Erase>]static member refetchWith<'U, 'T>(this: SolidResourceManager<'T>, input: 'U): JS.Promise<'T>SolidResourceState
type SolidResourceStateStringEnum with values:
| UnresolvedHasn't started loading, no value yet.
| PendingIt's loading, no value yet.
| ReadyFinished loading, has value.
| RefreshingIt's reloading, latest has value.
| ErroredFinished loading with an error, no value.
ResourceFetcher
type ResourceFetcher<'U, 'T> = 'U -> ResourceFetcherInfo<'T> -> JS.Promise<'T>Arguments that are available to consume within the handler. The first is the
source signal (if any was provided, else null), and the second is an object
with two properties: the previous value via _.value, and whether the fetcher
was initiated by a refetch via _.refetching.
ResourceFetcherInfo
type ResourceFetcherInfo<'T> = interfaceUsed in the handler parameter of the createResource function if using the
ResourceFetcher<'U, 'T> overload.
member value: 'TPrevious value.
member refetching: boolIs true when fetcher was triggered using the refetch function.
If refetch is called with an argument, that argument is supplied instead of
the boolean value.
Use _.refetchingWith helper if you are expecting this.
[<Extension; Erase>]static member refetchingWith<'T>(this: ResourceFetcherInfo<_>): U2<'T, bool>createRoot
let createRoot( // dispose fn fn: Action -> 'T ): 'TcreateUniqueId
let createUniqueId(): stringcreateStore
let createStore(store: 'T): 'T * SolidStoreSetter<'T>SolidStoreSetter
type SolidStoreSetter<'T> = interfacemember Update: newValue 'T -> unitReplace old store value with new value.
member Update: updater: ('T -> 'T) -> unitUpdate store mapping the old value to a new value.
member UpdatePath: pathArgs: obj[] -> unitUpdate store using native solid path syntax.
member Path: SolidStorePath<'T, 'T>Access more convenient method of updating store items.
SolidStorePath
type SolidStorePath<'T, 'Value> = interfacemember Setter: SolidStoreSetter<'T>member Path: obj[]member Map(map: 'Value -> 'Value2)Chooses the store item that should be updated.
member Update(value: 'Value): unitUpdate store item using new value
member Update(value: 'Value -> 'Value): unitUpdate store item mapping old value to new value.
[<Extension; Erase>]static member inline Item( this: SolidStorePath<'T, 'Value array>, index: int ): 'ValueSelect store item by index
[<Extension; Erase>]static member inline Find( this: SolidStorePath<'T, 'Value array>, predicate: 'Value -> bool ): 'ValueSelect store item by predicate
Example
type StoreValue = { MyValue: int }
let store,storeSetter = createStore<StoreValue>({ MyValue = 5 })JS.console.log store // { MyValue: 5 }storeSetter.Path.Map( _.MyValue ).Update(10)JS.console.log store // { MyValue: 10 }reconcile
let reconcile<'T, 'U>(value: 'T): ('U -> 'T)produce
let produce<'T>(fn: 'T -> unit)unwrap
let unwrap<'T>(item: 'T): 'Tbatch
let batch<'T>(fn: unit -> 'T): 'TExperimental CE
open Partas.Solid.Experimentalbatch { ... }catchError
let catchError<'T>( tryFn: unit -> 'T, onError: obj -> unit ): 'TonCleanup
let onCleanup(fn: unit -> unit): unitExperimental CE
open Partas.Solid.Experimentalcleanup { ... }onMount
let onMount(fn: unit -> unit): unitExperimental CE
open Partas.Solid.Experimentalmount { ... }useTransition
let useTransition(): (pending: unit -> bool) * (start: (unit -> unit) -> JS.Promise<unit>)startTransition
let startTransition(): (start: (unit -> unit) -> JS.Promise<unit>)untrack
let untrack<'T>(fn: Accessor<'T>): 'TimportComponent
let importComponent(path: string): JS.Promise<HtmlElement>Use to dynamically import a component (in combination with lazy), where path is the relative path to the
component declaring file.
The component must therefor be the default export of the file.
lazy
let lazy'(import: unit -> JS.Promise<HtmlElement>): HtmlElementComponent lazy loading. Use in combination with importComponent
createComputed
let createComputed<'T>( fn: 'T -> 'T, ?value: 'T ): unit| Param | Description |
|---|---|
fn | The function to run in a tracking scope. |
value | The initial value to pass to the function. |
createComputed creates a new computation that immediately runs the given function
in a tracking scope, thus automatically tracking its dependencies, and automatically
reruns the function whenever the dependencies changes.
The function gets called with an argument equal to the value returned from the functions last execution, or on the first call, equal to the optional second argument.
The return value of the function is not otherwise exposed; in particular,
createComputedhas no return value.
Before using createComputed consider using createMemo or createRenderEffect.
createComputed is the most immediate form of reactivity in solid-js, and is most useful
for building other reactive primitives.
For example, some other solid-js primitives are built from createComputed.
createComputed should be used with care, as it can easily cause more unnecessary
updates than other reactive primitives.
createDeferred
let createDeferred<'T>( source: unit -> 'T, ?timeoutMs: int, ?equals: (prev: 'T) -> (next: 'T) -> bool, ?name: string ): Accessor<'T>| Param | Desc |
|---|---|
source | |
timeoutMs | Maximum time to wait for the browser to go idle before forcing update |
?equals | Custom function comparison predicate |
?name | Name to use for debugging |
Creates a readonly that only notifies downstream changes when the browser is idle.
createReaction
let createReaction( onInvalidate: unit -> unit ): (unit -> unit) -> unitSometimes it is useful to separate tracking from re-execution. This primitive registers a side-effect that is run the first time the expression wrapped by the returned tracking is notified of a change.
createRenderEffect
let createRenderEffect<'T>( fn: 'T -> 'T, ?value: 'T ): unitA render effect is a computation similar to a regular effect, but differs in when solid-js
schedules the first execution of the effect function.
While createEffect waits for the current rendering phase to be complete, createRenderEffect
immediately calls the function. Thus the effect runs as DOM elements are being created
and updated, but possibly before specific elements of interest have been created,
and probably before those elements have been mounted.
In particular, refs will not be set before the initial effect call.
solid-js uses createRenderEffect to implement the rendering phase of itself,
including the setting of refs
createSelector
let createSelector<'T, 'U>( source: unit -> 'T, ?fn: 'U -> 'T -> bool ): 'U -> bool| Param | Desc |
|---|---|
source | The source signal to get the value from and compare with keys. |
fn | A function to compare the key and the value, returning whether they should be treated as equal. Default: = |
Creates a parameterised derived boolean signal selector(key) that indicates whether
key is equal to the current value of the source signal.
These signals are optimised to notify each subscriber only when their key starts
or stops matching the reactive source value (instead of every time key changes).
If you have n different subscribers with different keys, and the source value changes
from a to b, then instead of all n subscribers updating, at most two subscribers
will update:
The signal with
keyawill change tofalse.
The signal with
keybwill change totrue.
Thus it reduces from n updates to 2 updates.
Useful for defining the selection state of several selectable elements.
mapArray
let mapArray<'T, 'U>( source: Accessor<'T[]>, fn: 'T -> Accessor<int> -> 'U ): Accessor<'U[]>Reactive map helpers that caches each item by reference to avoid unnecessary recomputations. It only runs the mapping function once per value, and then moves or removes it as needed.
The index argument is a signal. The map function itself is not tracking.
This is the underlying helper for the For component, which is used to render
lists of items.
indexArray
let indexArray<'T, 'U>( source: Accessor<'T[]>, fn: Accessor<'T> -> int -> 'U ): Accessor<'U[]>Reactive helper that maps by index, similar to mapArray, but uses the index
of the item in the array as the key for the mapping function.
This is useful when you want to map over an array and use the index as a key for each item, such as when rendering a list of items with unique keys.
This is the underlying helper for the Index component, which is used to render lists
of items.
Last updated: 9/11/25, 8:36 AM