Skip to content

[Bug]: SSR Issue with localStorage in CursorifyProvider during Gatsby Build #4

Description

@Amirbeek

Describe the bug

Hello,

I’m encountering an issue with the @cursorify/react library while working with Gatsby. During the static HTML build process, I’m seeing the following error related to localStorage:

"localStorage" is not available during server-side rendering.
It seems that the CursorifyProvider component is trying to access localStorage during server-side rendering, which causes this error.

I’ve tried using dynamic imports and React.lazy() to prevent the issue, but the problem persists. Here’s the error trace for reference:

Steps to Reproduce:

Set up a Gatsby project with the latest version of @cursorify/react.
Use the CursorifyProvider component during the build process.
Run the build command (gatsby build).
Environment:

Gatsby version: Latest
@cursorify/react version: Latest
Node.js version: Latest
Has anyone encountered a similar issue or found a solution? Any guidance would be much appreciated.

Thank you in advance!

To reproduce

  1. Go to ...
  2. Click on ...
  3. Scroll down to ..
  4. See error

Browser

Windows 11

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions