Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not rendering in server side #31

Open
immanjeba75 opened this issue Sep 25, 2024 · 3 comments
Open

Not rendering in server side #31

immanjeba75 opened this issue Sep 25, 2024 · 3 comments

Comments

@immanjeba75
Copy link

Hi jonluca,
I am thankful to you for the code you provided on GitHub, it's working fine with the basic setup of your code, but the thing is I converted your code into my code, and it is working fine with client-side rendering, but it is not rendering in server side

how can I fix that?

@sifisatz
Copy link

sifisatz commented Oct 7, 2024

Hi @immanjeba75,

For the server-side rendering (SSR) issue you're facing, running yarn install is a great first step, but if the issue persists, try the following:

  1. Check for SSR compatibility: Some components or libraries might only work on the client-side. Ensure all libraries are SSR-compatible. If not, conditionally render them like this:

    if (typeof window !== 'undefined') {
      // client-side code
    }
    
  2. Update dependencies: Outdated dependencies might cause SSR issues. Run:

     yarn upgrade
     
    3. **Hydration issues**: If the server-side and client-side markup don't match, React might throw hydration warnings. Make sure the server is rendering the exact same markup as the client. Be careful with dynamic values like dates or random numbers.
  3. Server-side setup: Double-check your server configuration. If you're using a framework like Next.js, ensure the SSR-related setup is correct.

  4. Check error logs: Inspect both client and server logs for any errors or warnings that could point to the issue.

@immanjeba75
Copy link
Author

Hi @sifisatz,

Thank you for your comment. I have now completed both the server-side and client-side rendering setup. I have a few questions about how I can deploy this code to my server, how to use the build files on the server, and related topics. I don't have a clear idea about this process.

Additionally, I am struggling to generate a build for server-side rendering from my project. Do you have any suggestions or guidance on how I can achieve that?

Thanks in advance!

@aagamezl
Copy link

@immanjeba75 run npm run build, this script will build the application for production, the code is generated in the dist folder in the root of the project; this is the code that you need to deploy.

You need to run the npm run serve script to start the application in your production server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants