Expand description
A library for building reactive web apps
§Overview
- Pure rust API
- Fine grained reactivity using
futures_signals
- Routing
- Tauri support
- Server Side Rendering with hydration
§Book
The Silkenweb book provides a high level introduction to Silkenweb’s main concepts.
§Quick Start
First, install the wasm32
target:
rustup target add wasm32-unknown-unknown
Then install trunk:
cargo install trunk --locked
To run the example counter:
cd examples/counter
trunk serve --open
§Feature Flags
§weak-refs
Use Javascript weak references to manage event callbacks. This improves
performance but must be enabled in wasm-bindgen
. See the trunk
documentation for details on how to do this using data-weak-refs
.
See caniuse for current browser support.
§declarative-shadow-dom
Print Declarative Shadow DOM when server side rendering. Hydration will correctly deal with shadow DOM regardless of this flag. See caniuse for browser support. Polyfills are available.
§css-transpile
Enable CSS transpilation for css!
. This can significantly increase build
time, so is presented as an opt-in feature.
§Learning
There’s extensive documentation on each module in this crate, along with many other examples in the examples folder.
Reactivity is provided by futures_signals
. It would be helpful to
familiarize yourself using futures_signals::tutorial
.
Modules§
- animation
- Animation time signals.
- attribute
- Traits for defining attribute types.
- document
- Document utilities.
- dom
- An abstraction for the underlying DOM.
- elements
- HTML element types.
- hydration
- Hydrate the document with event handlers.
- node
- Generic DOM types.
- prelude
- Commonly used imports, all in one place.
- property
- Tools for working with Javascript properties.
- router
- URL based routing.
- storage
- Local and session storage.
- task
- Microtask and render queue tools.
- time
- Utilities for tacking time.
- value
- Abstract over the signal/value-ness of types.
- window
- Window utilities.
Macros§
- clone
- Clone all the identifiers supplied as arguments.
- css
- Define
&str
constants for each class in a CSS file. - custom_
html_ element - Define a custom html element.
- dbg
- This
dbg!
macro is a drop-in replacement forstd::dbg
- parent_
element - Add
child
andtext
methods to an html element. - shadow_
parent_ element - Implement
ShadowRootParent
for the HTML element
Functions§
- empty_
str - intern_
str - log_
panics - Log any
panic!
s to the browser console. This should ideally be the very first thing that is called, but can be omitted safely. Seeconsole_error_panic_hook
docs for more information. - mount
- Shorthand for
DefaultDom::mount
Attribute Macros§
Derive Macros§
- Aria
Element - Derive
AriaElement
- Child
Element - Derive the traits needed for a blanket implmenetation of
ChildElement
. - Element
- Derive
Element
. - Element
Events - Derive
ElementEvents
- Html
Element - Derive
HtmlElement
- Html
Element Events - Derive
HtmlElementEvents
- Value
- Derive
Value