Overview
If your app previously used Privy’s@privy-io/server-auth
SDK, follow the migration guide below to
upgrade to the @privy-io/node
package.
The new @privy-io/node
package is a major upgrade from the @privy-io/server-auth
package, with
an improved structure, error handling, and better support for the latest features available in
Privy’s API.
Initialization
0. System requirements
The new@privy-io/node
package, like its predecessor, is compatible with multiple server-side JavaScript runtimes.
Specifically, the following runtime versions are supported:
- Node.js 20 LTS or later (non-EOL) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Nitro v2.6 or greater.
1. Privy client initialization
ThePrivyClient
class now takes in a single configuration object, instead of
positional appId
and appSecret
parameters.
2. Working with resources
The new package splits different groups of methods into resource-specific interfaces. Whereas before you could call methods directly on thePrivyClient
instance, you now generally need
to call methods on the resource-specific interfaces.
The new SDK offers a one-to-one mapping of the API endpoints described in the API
reference. To facilitate this, methods called on the
PrivyClient
instance that need parameters to be passed in now take those in snake_case
instead of
camelCase
, matching the API format exactly.@privy-io/node
package, you will use the users()
interface:
walletApi
interface are now under the wallets()
or ` interface.
In @privy-io/server-auth | In @privy-io/node |
---|---|
privy.walletApi.createWallet | privy.wallets().create |
privy.walletApi.rpc | privy.wallets().rpc |
privy.walletApi.ethereum.signMessage | privy.wallets().ethereum().signMessage |
privy.walletApi.createPolicy | privy.policies().create |
3. Authorization signatures
The new package introduces theAuthorizationContext
interface,
which simplifies the process of generating authorization signatures.
The
privy.walletApi.generateUserSigner
method is no longer available in the @privy-io/node
package. Instead you can set the user_jwts
property on the authorization context, and the SDK
will handle the authorization keys automatically.