@emeraldpay/doubleview-react
v0.4.0
Published
Common utilities for Doubleview in React
Readme
@emeraldpay/doubleview-react
Common utilities for Doubleview React SSR implementation.
Installation
npm install @emeraldpay/doubleview-react
# or
pnpm add @emeraldpay/doubleview-reactUsage
Types
import { WebContextType, DoubleView } from '@emeraldpay/doubleview-react'Hooks
import { useWebContext, useAttributes, useAttribute } from '@emeraldpay/doubleview-react'
function MyComponent() {
// Access the full web context
const context = useWebContext()
// Access all attributes at once
const attributes = useAttributes()
// Access specific attributes with type safety
const userId = useAttribute<string>('userId')
const locale = useAttribute<string>('locale')
return (
<div>
<p>User ID: {userId}</p>
<p>Locale: {locale}</p>
</div>
)
}Utilities
import { isSSR, isClient } from '@emeraldpay/doubleview-react'Development
# Install dependencies
pnpm install
# Build the package
pnpm build
# Run in development mode (watch mode)
pnpm dev
# Type check
pnpm typecheck
# Lint
pnpm lintLicense
Apache 2.0
