@webflow/tsw
v0.13.0
Published
The .tsw toolchain in one package: the authoring API and runtime, the element library, the language engine and compiler, framework adapters for Astro, Next.js, and React, and the TypeScript editor plugin.
Readme
@webflow/tsw
Tooling for building Webflow sites in code. Pages and components are written in .tsw, a
TypeScript dialect of TSX, and render through Astro, Next.js, or React.
npm install @webflow/tsw@nextA component
// src/components/WindowBar.tsw
import {component, props, style} from '@webflow/tsw/core';
import {Block, Span} from '@webflow/tsw/ui';
const bar = style('window-bar', {display: 'flex', alignItems: 'center', gap: '8px'});
export default component({name: 'WindowBar', props: {title: props.Text({defaultValue: ''})}}, ({title}) => (
<Block class={bar}>
<Span>{title}</Span>
</Block>
));Set up your framework
// astro.config.mjs
import {defineConfig} from 'astro/config';
import react from '@astrojs/react';
import webflow from '@webflow/tsw/astro';
export default defineConfig({integrations: [react(), webflow()]});// next.config.mjs
import {withWebflow} from '@webflow/tsw/next/config';
export default withWebflow({
// your own Next config is preserved
});// vite.config.ts (plain React)
import {defineConfig} from 'vite';
import {webflowReactVite} from '@webflow/tsw/react/vite';
export default defineConfig({plugins: [webflowReactVite()]});Links between pages in Astro
Import the target page and pass it to Link:
import About from './about.tsw';
import {Link} from '@webflow/tsw/ui';
<Link to={About}>About</Link>;The Astro integration resolves static .tsw routes automatically—no middleware
file is needed. It uses Astro's resolved route manifest, including base and
trailingSlash, and updates the mapping when routes change during development.
The same mapping works during prerendering.
Dynamic routes have no single URL. For dynamic parameters, custom routing, or
request-dependent locale selection, supply your own resolver on
Astro.locals.pageHref. An explicit resolver replaces the default mapping;
null resets it. An unmapped page reference throws rather than silently linking
to the wrong page.
Check
npx tsw check srcAdd the TypeScript plugin for inline diagnostics and quick fixes in any tsserver-based editor:
// tsconfig.json
{
"compilerOptions": {
"plugins": [{"name": "@webflow/tsw/typescript"}],
},
}Entry points
| Import | What it is |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| @webflow/tsw/core | Authoring API used inside .tsw files: component(), page(), style(), props.* |
| @webflow/tsw/core/theme, /stdlib, /i18n | Theme modules, the typed stdlib, and locale bindings |
| @webflow/tsw/ui | The element library (Block, Section, Heading, forms, tabs, ...) |
| @webflow/tsw/astro, /next, /react | Framework adapters: Astro integration, Next.js config wrapper and LocaleBoundary, React renderer with a Vite plugin |
| @webflow/tsw/compiler, /compiler/vite | The compiler API, the Vite plugin, and the tsw CLI |
| @webflow/tsw/typescript | tsserver plugin: add {"name": "@webflow/tsw/typescript"} to compilerOptions.plugins |
| @webflow/tsw/lang | The language engine, for tools that analyze .tsw |
@webflow/tsw/runtime (styles and locale context) and @webflow/tsw/cms (CMS
reads) are emit targets for compiled modules; authors never import them.
The Astro integration also exports defaultPageHref from @webflow/tsw/astro,
which compiled Astro pages use for automatic route resolution.
The published package supports Node.js 22.13.0 and newer, the same floor as the
published @webflow/webflow-cli. Building this repository requires Node.js
22.23.5 or newer for its development tools.
Peer dependencies: react and typescript are required. astro, next,
and vite are optional and only needed by the entry that uses them.
