Skip to main content
Implementing Para in Create React App (CRA) projects with CRACO can present specific challenges. This guide provides targeted solutions and best practices to help you overcome common integration hurdles.
Using an LLM (ChatGPT, Claude) or Coding Assistant (Cursor, Github Copilot)? Here are a few tips:
  1. Include the for the most up-to-date help
  2. Check out the for an interactive LLM using Para Examples Hub

General Troubleshooting Steps

Before diving into specific issues, try these general troubleshooting steps:
bash rm -rf node_modules npm cache clean --force
bash npm install
bash npm run build

Common Issues and Solutions

Problem: CRA doesn’t include polyfills for certain Node.js modules that Para might depend on, such as buffer or crypto.Solution: Use CRACO to add the necessary polyfills and configurations. Adjust the configuration as needed for your specific requirements.
  1. Install CRACO and required packages:
    npm install @craco/craco crypto-browserify stream-browserify buffer
    
  2. Create or update your craco.config.js file:
    const webpack = require("webpack");
    
    module.exports = {
      webpack: {
        plugins: {
          add: [
            new webpack.ProvidePlugin({
              Buffer: ["buffer", "Buffer"],
            }),
          ],
        },
        configure: (webpackConfig) => {
          // ts-loader is required to reference external typescript projects/files (non-transpiled)
          webpackConfig.module.rules.push({
            test: /\.tsx?$/,
            loader: "ts-loader",
            options: {
              transpileOnly: true,
              configFile: "tsconfig.json",
            },
          });
          webpackConfig.resolve.fallback = {
            crypto: require.resolve("crypto-browserify"),
            stream: require.resolve("stream-browserify"),
            buffer: require.resolve("buffer"),
            url: false,
            zlib: false,
            https: false,
            http: false,
          };
          return webpackConfig;
        },
      },
    };
    
  3. Update your package.json scripts to use CRACO:
    "scripts": {
      "start": "craco start",
      "build": "craco build",
      "test": "craco test",
      "eject": "react-scripts eject"
    }
    
Problem: TypeScript compilation errors when using Para with CRA and CRACO.Solution: Ensure your tsconfig.json is properly configured. Adjust the settings as needed for your project:
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src"]
}
Problem: Environment variables not being recognized in your application. Solution: Ensure you’re prefixing your environment variables with REACT_APP_ and accessing them correctly: 1. In your .env file: REACT_APP_PARA_API_KEY=your_api_key_here 2. In your code: javascript const para = new Para(process.env.REACT_APP_PARA_API_KEY);
Problem: Para’s CSS files not loading correctly. Solution: Import Para’s CSS file in your main App.js or index.js:
import "@getpara/react-sdk/dist/index.css@alpha";
function App() {
  // Your app code
}
export default App;

Best Practices

  1. Use the Latest Versions: Always use the latest versions of CRA, CRACO, and Para SDK to ensure compatibility and access to the latest features.
  2. Error Handling: Implement error boundaries to gracefully handle any runtime errors related to Para integration.
  3. Development vs Production: Use environment-specific configurations to manage different settings for development and production builds. Para provides environment-specific API keys.
  4. Keep CRACO Config Clean: Only add necessary overrides in your CRACO configuration to avoid potential conflicts with CRA’s default settings.
By following these troubleshooting steps and best practices, you should be able to resolve most common issues when integrating Para with your Create React App project using CRACO.

Integration Support

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. 1

    A detailed description of the problem you’re encountering.

  2. 2

    Any relevant error messages or logs.

  3. 3

    Steps to reproduce the issue.

  4. 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.
I