Overcoming Para integration challenges in TanStack Start applications
TanStack Startβs server-side rendering (SSR) capabilities can introduce unique challenges when integrating Para SDK. This guide addresses frequent issues and offers tailored solutions to ensure a successful implementation.
Using an LLM (ChatGPT, Claude) or Coding Assistant (Cursor, Github Copilot)? Here are a few tips:
Before diving into specific issues, try these general troubleshooting steps:
Clear cache and node_modules
Reinstall dependencies
Update Para-related packages
Rebuild the project
Environment Variables Not Properly Configured
Problem: Para API key environment variables not being recognized in your application.
Solution: Ensure youβre using the correct prefix for environment variables in TanStack Start and accessing them properly:
In your .env
file:
In your constants file:
When using these in your ParaProvider:
Node.js Polyfills Missing or Misconfigured
Problem: Missing or improperly configured Node.js polyfills causing errors like crypto is not defined
or similar issues.
Solution: Configure the polyfills specifically for the client bundle only:
Install the plugin:
Update your app.config.ts
to apply polyfills only to the client bundle:
Important: Do NOT configure nodePolyfills in the top-level vite plugins array, as this will apply the polyfills to the server bundle and can cause conflicts.
Missing process.browser Configuration
Problem: Browser-specific modules not being resolved correctly, leading to missing APIs or incorrect environment detection.
Solution: Add the process.browser
definition to help modules determine the execution environment:
This setting is critical for ensuring that browser-specific code paths are correctly resolved during bundling.
Styled-Components Errors During Server Rendering
Problem: Errors like styled.div is not a function
or Cannot read properties of undefined (reading 'div')
during server rendering.
Solution: Ensure Para components are only rendered on the client side by using both React.lazy
for dynamic imports and ClientOnly
from TanStack Router:
The combination of React.lazy
and ClientOnly
ensures that Para components are not only rendered on the client side but also that the modules are not evaluated on the server.
Styled-Components Issues Despite ClientOnly Usage
Problem: Even with ClientOnly
, youβre still seeing styled-components errors during server rendering.
Solution: Module-level evaluation can still happen on the server even if the component isnβt rendered. Make sure all Para imports are lazy loaded:
Donβt import directly from Para SDK at the module level:
Instead, create wrapper components for all Para components:
Then lazy load these wrapper components:
CSS Styling Issues or Transparent Modal
Problem: The Para modal appears transparent or without proper styling.
Solution: Import Paraβs CSS file in your component:
Ensure this import is included in the component that uses Para components or in a parent component that wraps them.
Client-Side Only Rendering: Always use both React.lazy
and ClientOnly
for Para components to avoid SSR issues.
Polyfill Strategy: Configure node polyfills only for the client bundle using the routers.client.vite.plugins
config.
Environment Awareness: Set process.browser
to true to help modules determine the execution environment.
Component Boundaries: Clearly define boundaries between server and client components to prevent hydration mismatches.
Error Handling: Implement error boundaries to gracefully handle any runtime errors related to Para integration.
Development vs Production: Use environment-specific configurations to manage different settings for development and production builds.
By following these troubleshooting steps and best practices, you should be able to resolve most common issues when integrating Para with your TanStack Start application.
If youβre experiencing issues that arenβt resolved by our troubleshooting resources, please contact our team for assistance. To help us resolve your issue quickly, please include the following information in your request:
1
A detailed description of the problem youβre encountering.
2
Any relevant error messages or logs.
3
Steps to reproduce the issue.
4
Details about your system or environment (e.g., device, operating system, software version).
Providing this information will enable our team to address your concerns more efficiently.