elegance-js
v3.2.3
Published
Elegance is the web-framework of the future. With FS-routing, dynamic SSR, middleware, type-safety, JSX, automatic Image optimization, zero client dependencies, and blazing speed; with Elegance you can create safer, faster and simpler web.
Maintainers
Readme
Elegance
Our Website
Elegance is the web-framework of the future. With FS-routing, dynamic SSR, middleware, type-safety, JSX, automatic Image optimization, zero client dependencies, and blazing speed; with Elegance you can create safer, faster and simpler web.
Features
- Ridiculous speed: Up to ~24x faster build times compared to Next.JS, and up to ~1400x raw RPS on API Routes.
- Optimized: 4KB client runtime
- File‑system routing: pages and API endpoints are defined by the directory structure.
- TSX support: use TSX with no runtime overhead.
- Server & Client hybrid: You can write server & client-code in 1 file with no issues.
- Reactive: atoms and components with automatic dependency tracking.
- Dynamic rendering: opt into per‑request rendering or statically enumerate paths.
- Server Actions: Inline API routes into your page files for faster development times.
- Middleware: scoped request processing with the ability to pass data to downstream handlers.
- Built‑in bundling: code splitting and advanced dead‑code elimination (DCE).
- API routes: define
GET,POST,PUT,DELETE, andOPTIONShandlers. - Styling: CSS, CSS Modules, and hooks for Sass/PostCSS/Tailwind.
- Image Optimization: Reference 10Mb images in your code with no worries, Elegance automatically generates resized versions for all necessary sizes.
Quick Start
npx create-elegance-app my-app
cd my-app
npx eleganceVisit http://localhost:3000 to see the default page.
Example
A simple counter:
const counter = atom(0);
export default function CounterPage() {
return div(
button({
onClick: () => counter.value++,
},
`Counter: ${counter.value}`
)
);
}
// JSX is also supported!A reusable component version:
const Counter = component({
atoms: {
counter: 0,
},
view(_, { counter }) {
return button({
onClick: () => counter.value++,
},
`Counter: ${counter.value}`
);
}
});
export default function Page() {
return Counter();
}Styling
Extending styling is incredibly easy. Import stylesheets from any page, layout, or client component with no hassle.
import "./styles/global.css"; // global stylesheet
import styles from "./hero.module.css"; // CSS Module
export default function Page() {
return div({ className: styles.hero }, "Scoped!");
}import sass from "sass";
export const config: EleganceConfig = {
css: {
transformers: [
{ test: /\.scss$/, transform: (source, file) => sass.compileString(source, { loadPaths: [file] }).css },
],
},
};.scss, .sass, .less, .styl, .pcss/.postcss and .css files are all picked up automatically.
Project Structure
my-app/
├── pages/
│ ├── page.tsx # / (home)
│ ├── about/
│ │ └── page.tsx # /about
│ ├── api/
│ │ └── route.ts # /api/*
│ ├── [slug]/
│ │ └── page.tsx # dynamic routes
│ └── middleware.ts # global middleware
└── ...Documentation
Full documentation is available via Our Website Performance results, as well as methodology are available here
License
MIT
