Documentation
Everything you need to start using RSFC in your React project.
Your First Component
A counter with state, a CSS Module, and auto-scoped styles — all in one file. The styles object is injected automatically when a <style module> block is present.
Quick Start
Vite
Next.js
TypeScript
Add a declaration file so TypeScript recognises .rsfc imports:
Blocks
| Block | Description |
|---|---|
<script setup lang="ts"> | Shorthand — imports hoisted, code runs in component scope, default export generated automatically |
<script lang="ts"> | Full control — write and export the component function yourself |
<template> | JSX returned by the component. styles is in scope automatically when a <style module> block is present |
<style module> | CSS Modules — class names are hashed, styles.* injected into scope |
<style scoped> | Scoped via a unique data-v-* attribute — no class renaming |
<style lang="scss"> | Preprocessor support (Sass, Less, Stylus) |
<clientScript> | Browser-only code, skipped during SSR |
<docs> | Embedded Markdown documentation, readable via parseFile() |
<anything> | Custom blocks — handle via customBlockTransforms in the plugin |
script vs script setup
<script setup> is the shorthand: variables are in scope and the default export is generated for you. <script> gives full control — write and export the function yourself.
Plugin Options
| Option | Type | Default | Description |
|---|---|---|---|
include | string[] | ['**/*.rsfc'] | Glob patterns of files to transform |
exclude | string[] | ['node_modules/**'] | Glob patterns of files to skip |
customBlockTransforms | Record<string, Function> | — | Transform custom blocks to JavaScript by tag name |
CLI
Compile or inspect any .rsfc file without a bundler:
| Command | Description |
|---|---|
rsfc compile <file> | Compile .rsfc to JavaScript (stdout) |
rsfc compile <file> -o <out> | Compile and write to file |
rsfc parse <file> | Parse and emit JSON descriptor (stdout) |
Packages
| Package | Description |
|---|---|
@g-casau/rsfc-vite-plugin | Vite plugin |
@g-casau/rsfc-webpack-loader | Webpack / Next.js loader |
@g-casau/rsfc-core | Parser + generator — zero runtime deps |
@g-casau/rsfc-cli | CLI (rsfc compile, rsfc parse) |
VS Code Extension
Install the RSFC extension for syntax highlighting, IntelliSense, and CSS Module autocompletion.
Download .vsix from GitHub ReleasesInstall via Extensions → Install from VSIX… in VS Code.
AI Setup
Add RSFC context to your AI editor so it understands the format and generates correct files. Copy this snippet into your CLAUDE.md, .github/copilot-instructions.md, or .cursorrules: