The entry point of @just-web
application framework.
# npm
npm install @just-web/app
# yarn
yarn add @just-web/app
# pnpm
pnpm install @just-web/app
#rush
rush add -p @just-web/app
Using a simple React app as an example:
import { createApp } from '@just-web/app'
import { AppContext } from '@just-web/react'
import ReactDOM from 'react-dom'
import App from './App'
void (async () => {
const app = createApp().extend(...)
await app.start()
ReactDOM.render(
<React.StrictMode>
<AppContext.Provider value={app}>
<App />
</AppContext.Provider>
<React.StrictMode>,
document.getElementById('root')
)
})
Your logics can be implemented as plugins.
The plugin can get the dependencies it needs through the init()
function, or through useAppContext()
for React components.
import { definePlugin } from '@just-web/types'
const plugin = definePlugin(() => {
name: 'your-feature',
init(ctx: ContextThatYouNeed) { ... }
})
import { useAppContext } from '@just-web/react'
const Comp = () => {
const ctx = useAppContext<ContextThatYouNeed>()
return <div>{ctx.auth.id}</div>
}
Generated using TypeDoc