The `unicornstudio-react` package provides a community-created React component for embedding interactive 3D scenes designed with Unicorn.Studio into web applications. Currently at version `2.1.4-1`, this library sees frequent updates, often involving bumps to the underlying Unicorn.Studio SDK and fixes for compatibility issues in modern React and Next.js environments. Key differentiators include full TypeScript support, an optimized import path specifically for Next.js applications (leveraging Next.js `Script` and `Image` components), performance optimizations like lazy loading, responsive design, and comprehensive error handling. It allows embedding scenes using either a project ID from Unicorn.Studio's cloud service or a local JSON file. It's important to note that this package is not officially affiliated with Unicorn.Studio and relies on their proprietary script and services.
npm install unicornstudio-reactVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates embedding a Unicorn.Studio interactive scene using the Next.js optimized component, including loading and error handling. It fetches a project ID from environment variables and sets various display properties.
Understand the external dependencies; ensure Unicorn.Studio services are operational and your project ID or JSON file path is correct. Check Unicorn.Studio's official documentation for service status.
Always review the Unicorn.Studio SDK changelog and `unicornstudio-react` release notes before upgrading major versions of the SDK. Test thoroughly after any updates.
Upgrade to `unicornstudio-react@2.1.4-1` or higher. Always use the Next.js-optimized import path: `import UnicornScene from 'unicornstudio-react/next';` to benefit from specific optimizations and bug fixes.
For all Next.js projects, consistently use `import UnicornScene from 'unicornstudio-react/next';` to ensure optimal performance and compatibility.
Update to `unicornstudio-react@2.1.4-1` or newer. Ensure React Strict Mode is compatible or consider adjusting component keys if custom rendering logic is involved.
Verify that your `projectId` is correctly copied from Unicorn.Studio or that `jsonFilePath` points to an accessible JSON file. Check the browser console for network errors, JavaScript errors, or CSP violations. Ensure `https://cdn.jsdelivr.net` and `https://assets.unicorn.studio` are allowed in your CSP.
Check for typos in `import UnicornScene from 'unicornstudio-react/next';`. Ensure `npm install unicornstudio-react` or `yarn add unicornstudio-react` was run successfully. If using an older bundler, ensure it supports the `exports` field in `package.json`.
Ensure external script loading is not blocked by a Content Security Policy (CSP). Check network requests in developer tools to confirm the script (`unicornStudio.umd.js`) is loading. The component handles script loading automatically, but external factors can interfere. Consider using the `onLoad` prop to ensure readiness if manually interacting with the SDK or deferring related logic.