Pulse

Pulse (Python)

Core Python API exports from pulse.__init__

This is the complete API reference for the main pulse package. Every export listed here is available directly from the top-level import:

import pulse as ps

New to Pulse? This reference is designed for quick lookups, not learning. If you're just getting started, head to the Guide for explanations and examples, or the Tutorial for a hands-on walkthrough.


App and Routing

These are the building blocks for creating your application and defining its URL structure. Every Pulse app starts with an App instance and one or more Route definitions.

ExportDescription
AppMain application class
RouteRoute definition
LayoutLayout wrapper for nested routes
RouteInfoTypedDict with current route information
PulseModeLiteral type: 'single-server' or 'subdomains'
CodegenConfigCode generation configuration

Components

Components are the core abstraction in Pulse. Use the @component decorator to create reusable UI pieces, and the helpers below to control rendering flow.

ExportDescription
componentDecorator to define a Pulse component
ComponentComponent class (created by decorator)
ForMap items to elements with automatic key handling
IfConditional rendering helper
LinkClient-side navigation link
OutletRenders child routes in layouts

State and Reactivity

Pulse's reactivity system automatically tracks dependencies and updates the UI when data changes. Signal holds values, Computed derives from them, and Effect runs side effects. For complex state, extend the State class.

ExportDescription
StateStateful class base for component state
SignalReactive value container
ComputedDerived reactive value
EffectSide effect that tracks dependencies
AsyncEffectAsync side effect
BatchContext manager to batch reactive updates
UntrackContext manager to read without tracking
computedDecorator to make a method computed
effectDecorator to make a method an effect
ReactiveListReactive list container
ReactiveDictReactive dict container
ReactiveSetReactive set container

Hooks

Hooks let you tap into the component lifecycle. Use them inside component functions to run setup code, access state, or manage cleanup.

ExportDescription
initRun code once when component mounts
setupRun setup code with cleanup
setup_keyKeyed setup for dynamic dependencies
stateAccess component state instance
effectsRegister effects in component
stableGet stable reference across renders

Runtime Hooks

These hooks access runtime context during rendering: the current route, session data, navigation, and more. Call them inside components to interact with the request lifecycle.

ExportDescription
routeGet current RouteContext
sessionGet current session data dict
session_idGet current session ID
websocket_idGet current WebSocket connection ID
navigateNavigate to a URL
redirectRedirect and stop rendering
not_foundReturn 404 and stop rendering
call_apiCall a server API endpoint
set_cookieSet a cookie on the client
global_stateAccess global state by type

Queries

Queries handle server-side data fetching with automatic caching, refetching, and loading states. Use query for reads, mutation for writes, and infinite_query for paginated data.

ExportDescription
queryDefine a data query
mutationDefine a data mutation
infinite_queryDefine an infinite/paginated query
QueryClientQuery cache and management

Forms

Built-in form handling with typed data extraction. Form handles submission automatically; use ManualForm when you need custom submit behavior.

ExportDescription
FormForm component with automatic handling
ManualFormForm with manual submit control
FormDataTyped form data container
FormValueSingle form field value
UploadFileUploaded file (from starlette)

Channels

Channels enable real-time bidirectional communication between server and client. Useful for chat, live updates, and streaming data.

ExportDescription
channelCreate a bidirectional channel
ChannelChannel instance type
ChannelClosedException for closed channel
ChannelTimeoutException for channel timeout

Serialization

Low-level utilities for converting Python objects to JSON-compatible formats for WebSocket transport. Most apps won't need these directly.

ExportDescription
serializeSerialize Python values for transport
deserializeDeserialize transported values

JavaScript Interop

Bridge between Python and JavaScript. Use @javascript to transpile Python functions to JS, Import to bring in npm packages, and react_component to wrap existing React components.

ExportDescription
javascriptDecorator for Python-to-JS transpilation
JsFunctionTranspiled JS function type
ImportImport a JS module or symbol
react_componentWrap a React component for use in Pulse
run_jsExecute arbitrary JS on the client

Middleware

Middleware intercepts requests before they reach your components. Use it for authentication, logging, redirects, and other cross-cutting concerns.

ExportDescription
stackCreate middleware stack
PulseMiddlewareBase middleware class
MiddlewareStackMiddleware chain
LatencyMiddlewareAdd artificial latency (dev)
RedirectMiddleware redirect response
NotFoundMiddleware 404 response
OkMiddleware success response
DenyMiddleware deny response

Cookies and Sessions

Manage client cookies and server-side session storage. Sessions persist user data across requests.

ExportDescription
CookieCookie configuration
SetCookieCookie with value to set
SessionStoreAbstract session storage
CookieSessionStoreJWT-based cookie sessions

Context

Access the current request context. Useful for advanced scenarios where you need direct access to the underlying request.

ExportDescription
PulseContextCurrent request context
PulseRequestIncoming request wrapper

Plugin System

Extend Pulse with custom functionality. Plugins can hook into the app lifecycle to add features like authentication providers or analytics.

ExportDescription
PluginBase class for app plugins

Helpers

Miscellaneous utilities for common tasks.

ExportDescription
CSSPropertiesTypedDict for inline styles
repeatRepeat a value n times
laterSchedule a callback after delay

VDOM Types

Type annotations for Pulse's virtual DOM. Use these for type hints in components that return or manipulate elements.

ExportDescription
ElementJSX/HTML element node
NodeAny renderable node
PulseNodeServer component instance
Primitivebool, int, float, str, None

Event Handler Types

Type annotations for event handlers with varying argument counts. Useful for strict typing of callbacks.

ExportDescription
EventHandler0Handler with 0 extra args
EventHandler1Handler with 1 extra arg
EventHandler2Handler with 2 extra args
...Up to EventHandler10

Environment

Access environment variables and detect the current runtime mode (development, CI, or production).

ExportDescription
PulseEnvLiteral type: 'dev', 'ci', 'prod'
envEnvironment variables accessor
mode()Get current PulseEnv

On this page