Modern SPA framework with reactivity, routing, and performance optimizations.
- Reactivity - Signals, computed values, and effects
- JSX - Full JSX syntax support
- Routing - Hash and History modes with guards
- Performance - Memoization, virtualization, lazy loading
- DevTools - Visual reactivity debugging
- TypeScript - Complete type safety
npm install drift-spaimport { createSignal, createApp, type FC } from 'drift-spa';
const Counter: FC = () => {
const [count, setCount] = createSignal(0);
return (
<div>
<p>Count: {() => count()}</p>
<button onClick={() => setCount(c => c + 1)}>+</button>
</div>
);
};
createApp(Counter).mount('#app');Creates a reactive signal.
const [count, setCount] = createSignal(0, 'counter');Creates a computed value.
const doubleCount = createComputed(() => count() * 2);Creates an effect that runs when dependencies change.
effect(() => {
console.log('Count changed:', count());
});Batches multiple updates.
batch(() => {
setCount(c => c + 1);
setStep(s => s + 1);
});Creates a router with History and Hash mode support.
const { RouterView, push, context } = createRouter({
mode: 'hash',
routes: {
'/': HomePage,
'/user/:id': UserPage,
'/about': AboutPage
},
beforeEach: (to, from) => {
console.log(`Navigate: ${from} β ${to}`);
return true;
}
});Simplified hash router.
const { RouterView, push } = createHashRouter({
'/': HomePage,
'/about': AboutPage
});Component memoization.
const MemoComponent = memo(({ data }) => {
return <div>{data.name}</div>;
});List virtualization.
<VirtualList
items={largeArray}
itemHeight={50}
containerHeight={400}
renderItem={(item, index) => <Item key={index} data={item} />}
/>Lazy component loading.
const LazyComponent = lazy(() => import('./HeavyComponent'));Enables the debugging panel.
import { devtools } from 'drift-spa';
if (import.meta.env.DEV) {
devtools.enable();
}Hotkeys: Ctrl+Shift+D
import { createSignal, createComputed, createApp, type FC } from 'drift-spa';
const Counter: FC = () => {
const [count, setCount] = createSignal(0);
const doubleCount = createComputed(() => count() * 2);
return (
<div>
<h1>Counter: {() => count()}</h1>
<p>Double: {() => doubleCount()}</p>
<button onClick={() => setCount(c => c + 1)}>+</button>
<button onClick={() => setCount(0)}>Reset</button>
</div>
);
};
createApp(Counter).mount('#app');import { createRouter, createSignal, type FC } from 'drift-spa';
const UserPage: FC<{ params: { id: string } }> = ({ params }) => {
const [user, setUser] = createSignal(null);
effect(() => {
fetchUser(params.id).then(setUser);
});
return (
<div>
<h1>User: {() => user()?.name}</h1>
<p>ID: {params.id}</p>
</div>
);
};
const { RouterView } = createRouter({
mode: 'history',
routes: {
'/user/:id': UserPage
}
});import { memo, VirtualList } from 'drift-spa';
const UserCard = memo(({ user }) => (
<div style={{ padding: '8px', border: '1px solid #ccc' }}>
<h3>{user.name}</h3>
<p>{user.email}</p>
</div>
));
const UserList = ({ users }) => (
<VirtualList
items={users}
itemHeight={80}
containerHeight={400}
renderItem={(user) => <UserCard key={user.id} user={user} />}
/>
);git clone https://github.com/nomad-pixel/driftjs
cd driftjs
pnpm install
pnpm devdriftjs/
βββ packages/
β βββ runtime/ # Main package
β βββ src/
β β βββ reactivity.ts # Reactivity
β β βββ jsx-runtime.ts # JSX support
β β βββ router.ts # Routing
β β βββ performance.ts # Optimizations
β β βββ devtools.ts # DevTools
β β βββ types.ts # Types
β β βββ index.ts # Exports
β βββ dist/ # Build output
βββ examples/
βββ counter-vite/ # Example app
pnpm buildpnpm testMIT
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- GitHub Issues
- Discord: #drift-framework
- Email: [email protected]
Drift SPA Framework - Modern SPA framework for building fast and responsive web applications.