The ultimate isomorphic web framework
🛠 Currently under active development, contributions are welcome
⚠️ Caution: This framework uses Node.js experimental async_hooks,There is a large performance loss at present, see: Node.js Benchmark Results
The goal of Wed.js is to unify the front-end and back-end development experience and return to the simplest functional programming.
No tedious abstractions anymore, develop Node.js as Lambda functions
lambda/date.ts
export async function getDate() {
return new Date().toString()
}
Developed on one code bases, calls the Node.js Lambda function directly
app/App.tsx
import { usePromise } from 'wedjs/ssr'
import { getDate } from '../lambda/date'
export default function App() {
const { data: date, loading, error } = usePromise(() => getDate())
if(loading) return <div>Loading</div>
if(error) return <code>{error}</code>
return <div>{date}</div>
}
asynchronous DOM rendering based on Promise Hooks, no getInitialProps
needed.
app/Stargazers.tsx
import { usePromise } from 'wedjs/ssr'
async function fetchStargazers(repo: string) {
const res = await fetch('https://api.github.com/repos/' + repo)
return await res.json()
}
export default function Stars() {
// Loads data on both client-side and server-side
const { data, loading, error } = usePromise(() => fetchStargazers('yenkn/wed.js'))
if(loading) return <div>Loading</div>
if(error) return <code>{error}</code>
return <div>{data.stargazers_count} Stars</div>
}
git clone https://github.com/yenkn/wed.js
cd wed.js
yarn