@ebitex/content-sdk
v0.20.92
Published
Consume published ebitex Content from your own site: a typed Delivery API client and React rendering utilities.
Downloads
4,500
Readme
@ebitex/content-sdk
Consume published ebitex Content from your own site: a typed client for the Content Delivery API and React utilities that render a delivered page by dispatching each Presentation to a component you provide.
Two entry points:
@ebitex/content-sdk— the clients.createDeliveryClientis one method per endpoint;createContentClientadds site/locale/context resolution, a resolve strategy, caching and cancellation, andresolveLocation(location)to call on every router change. No React.@ebitex/content-sdk/react—<ContentProvider>,<Experience>,<RenderPresentation>,<PresentationList>,<RichText>,<Resolve>, and a guiding fallback for every Presentation that cannot be rendered. React is a peer dependency, never bundled.
A browser-safe delivery key (one with an allowed-origins or allowed-IP-ranges restriction) may ship in a bundle. A key with neither restriction is a server-side key and must never reach a browser. Create either in Content → Delivery.
Install
npm install @ebitex/content-sdkQuick start
import { createContentClient } from '@ebitex/content-sdk'
import { ContentProvider, Experience, renderersFromGlob } from '@ebitex/content-sdk/react'
const content = createContentClient({ apiKey: import.meta.env.VITE_CONTENT_DELIVERY_KEY })
const renderers = renderersFromGlob(import.meta.glob('./presentations/*.tsx'))
export function App() {
const location = useLocation()
const navigate = useNavigate()
return (
<ContentProvider client={content} renderers={renderers} markdown={Markdown}>
<Experience path={location.pathname} onRedirect={(to) => navigate(to, { replace: true })} />
</ContentProvider>
)
}// presentations/hero.tsx — one file per Template, named by its externalId, default export
import type { PresentationRenderer } from '@ebitex/content-sdk/react'
const Hero: PresentationRenderer<{ headline: string }, { theme: string }> = ({ settings, component }) => (
<section data-theme={settings.theme}>
<h1>{component.content.headline}</h1>
</section>
)
export default HeroA Template with no renderer, an unpublished reference, a binding that needs server-side resolution — each renders a panel naming the reason and the fix, so a missing piece is visible, never silent.
Full guide and reference: developers.ebitex.io.
Worked examples: the ebitex samples repository has two complete Northwind Coffee sites built on this package, one static and one server-rendered, each with the content model it expects.
