@oddjs/preact
v0.3.0
Published
ODD SDK Preact hooks and context provider.
Downloads
11
Readme
odd-preact
ODD SDK Preact hooks and context provider.
Install
pnpm install @oddjs/preact
Usage
// app.jsx
import { OddContextProvider } from '@oddjs/preact'
/** @type {import('@oddjs/odd').Configuration} */
const config = {
namespace: {
creator: document.location.host,
name: 'Passkey auth',
},
}
export function App() {
return (
<>
<OddContextProvider
config={config}
componentsFactory={OddPasskey.createComponents}
>
<main className="App">
<Home path="/" />
</main>
</OddContextProvider>
</>
)
}
// home.jsx
import { useOddContext } from '@oddjs/preact'
export default function Home(props) {
const { session, isLoading, login, logout, register } = useOddContext()
}
// home.jsx with preact-router
import { useOdd } from '@oddjs/preact/router'
export default function Home(props) {
const { session, isLoading, login, logout, register } = useOdd({
redirectTo: '/login',
})
}
Docs
Check https://oddsdk.github.io/passkeys/modules/_oddjs_preact.html