TanStack Start is a full-stack React framework powered by TanStack Router. Para SDK uses styled-components internally which requires client-side only loading to work correctly with SSR.
Prerequisites
Before starting, you’ll need a Para API key which you can obtain from the . You can learn to create your account and get your API key from the Developer Portal.Installation
Install the Para React SDK and React Query:Using wagmi v3? See additional dependencies required.
Setting Up Polyfills with TanStack Start
Since TanStack Start uses Vite under the hood, we need to set up polyfills for modules like crypto, buffer, etc. that Para SDK relies on. We only want to run these polyfills on the client, not on the server.- Install the Vite Node Polyfills plugin:
- Configure the polyfills in your
app.config.ts:
app.config.ts
Setup Postinstall Script
Add the Para setup script to yourpackage.json:
package.json
Create a Client-Only Providers Component
Create a providers component using React.lazy and ClientOnly to ensure Para SDK only loads on the client:src/components/Providers.tsx
If you’re using a legacy API key (one without an environment prefix) you must provide a value to the
paraClientConfig.environment. You can retrieve your updated API key from the Para Developer Portal at https://developer.getpara.com/Wrap Your App with Providers
Update your root component to wrap your application with the Providers component:src/routes/__root.tsx
You can learn more about the
ParaProvider and its definition in the .The
ParaProvider utilizes libraries like Wagmi, Graz, and Solana Wallet Adapter, to power wallet connections. Meaning you can use any of the hooks provided by these libraries when within the ParaProvider context. You can learn more about using external wallets in the .Create a Client-Only Connect Component
Create a component that uses Para SDK hooks, ensuring it’s only rendered on the client:src/components/ParaContainer.tsx
Learn more about the hooks used in this example:
- - Control the Para modal programmatically (openConnectModal, openWalletModal)
- - Get account connection status and wallet details
src/routes/index.tsx
Why Client-side Only Loading?
Why Client-side Only Loading?
The Para SDK uses styled-components internally which can cause issues during server-side rendering. By using
React.lazy and ClientOnly, we ensure Para components are only evaluated in the browser environment where styled-components works correctly.