BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/paddle/paddle-client

Paddle client utilities

paddle/paddle-client
FreeUtility

Paddle.js initialization singleton, SDK type re-exports, checkout event mapper, and SDK-layer hooks used by all client-side Paddle blocks.

Install it

npx shadcn@latest add https://developer.paddle.com/r/paddle-client.json

Source

registry/new-york/blocks/paddle-client/lib/hooks/use-paddle-prices.tsxdeveloper.paddle.com/r/paddle-client.json
1"use client"
2
3import {
4 type Environments,
5 type Paddle,
6 type PricePreviewParams,
7 type PricePreviewResponse,
8} from "@paddle/paddle-js"
9import { useEffect, useState, useRef, useCallback } from "react"
10import {
11 formatBillingCycle,
12 formatTrialPeriod,
13} from "@/registry/new-york/blocks/paddle-helpers/lib/paddle-format"
14import { getOrCreatePaddle } from "@/registry/new-york/blocks/paddle-client/lib/paddle-instance"
15import type { PriceData } from "@/registry/new-york/blocks/paddle-helpers/lib/paddle-types"
16
17export type UsePaddlePricesArgs = {
18 clientToken: string
19 environment?: Environments
20 priceIds: string[]
21 countryCode?: string
22 discountId?: string
23}
24
25type PaddlePrices = Record<string, PriceData>
26
27function getPriceAmounts(prices: PricePreviewResponse): PaddlePrices {
28 return prices.data.details.lineItems.reduce((acc, item) => {
29 const hasDiscount = item.discounts.length > 0
30 acc[item.price.id] = {
31 total: item.formattedTotals.total,
32 originalTotal: hasDiscount ? item.formattedTotals.subtotal : undefined,
33 interval: formatBillingCycle(item.price.billingCycle),
34 trialPeriod: item.price.trialPeriod ? formatTrialPeriod(item.price.trialPeriod) : undefined,
35 }
36 return acc
37 }, {} as PaddlePrices)
38}
39
40export function usePaddlePrices(args: UsePaddlePricesArgs): {
41 prices: PaddlePrices
42 loading: boolean
43 error: Error | null
44} {
45 const { clientToken, environment = "production", priceIds, countryCode, discountId } = args
46 const [paddle, setPaddle] = useState<Paddle | null>(null)
47 const [prices, setPrices] = useState<PaddlePrices>({})
48 const [loading, setLoading] = useState<boolean>(true)
49 const [error, setError] = useState<Error | null>(null)
50
51 // Stable keys — prevent unnecessary re-fetches
52 const priceIdsKey = priceIds.join(",")
53 const discountIdKey = discountId ?? ""
54
55 // Initialize Paddle once
56 useEffect(() => {
57 if (paddle || !clientToken) return
58
59 getOrCreatePaddle(clientToken, environment)
60 .then((paddleInstance) => {
61 if (paddleInstance) {
62 setPaddle(paddleInstance)
63 }
64 })
65 .catch((err) => {
66 setError(err instanceof Error ? err : new Error("Failed to initialize Paddle"))
67 setLoading(false)
68 })
69 }, [clientToken, environment, paddle])
70
71 // Fetch prices when Paddle is ready or inputs change
72 const fetchedRef = useRef<string | null>(null)
73
74 const fetchPrices = useCallback(async () => {
75 if (!paddle) return
76
77// … truncated

What it pulls in

npm packages

  • @paddle/paddle-js

Other registry items

  • @paddle/paddle-helpers

Files it writes

  • registry/new-york/blocks/paddle-client/lib/paddle-instance.ts
  • registry/new-york/blocks/paddle-client/lib/paddle-sdk-types.ts
  • registry/new-york/blocks/paddle-client/lib/hooks/use-paddle-prices.tsx
  • registry/new-york/blocks/paddle-client/lib/hooks/use-checkout.tsx

Facts

Registry
paddle
Type
registry:lib
Access
Free
Files written
4
Licence
Apache-2.0
First indexed
2026-08-01
Last confirmed
today

Go to the source

developer.paddle.com PaddleHQ/paddle-ui on GitHub Raw registry item This item as JSON

More from paddle

All 14 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Paddle helperspaddle-helperspaddleUtilitiesFreeno deps · 4 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex