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

getServerSideProps Export Error #213

Closed
hulxv opened this issue Oct 30, 2021 · 8 comments
Closed

getServerSideProps Export Error #213

hulxv opened this issue Oct 30, 2021 · 8 comments

Comments

@hulxv
Copy link

hulxv commented Oct 30, 2021

When I try use getServerSideProps I got this error build:

Error occurred prerendering page "/[interval]". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Error for page /[interval]: pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export
    at /home/mohamed/Desktop/vnstat-client/node_modules/next/dist/export/worker.js:227:27
    at async Span.traceAsyncFn (/home/mohamed/Desktop/vnstat-client/node_modules/next/dist/telemetry/trace/trace.js:60:20)
info  - Exporting (2/2)
Error: Export encountered errors on following paths:
        /[interval]
    at /home/mohamed/Desktop/vnstat-client/node_modules/next/dist/export/index.js:487:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (/home/mohamed/Desktop/vnstat-client/node_modules/next/dist/telemetry/trace/trace.js:60:20)


Cannot build electron packages:
Error: Command failed with exit code 1: next export -o /home/mohamed/Desktop/vnstat-client/app /home/mohamed/Desktop/vnstat-client/renderer

I went to https://nextjs.org/docs/messages/gssp-export and I found that solution
Screenshot_20211031_004046

But how can do that in nextron ?

scripts in package.json:

"scripts": {
    "dev": "nextron --port 12999",
    "build": "nextron build --linux",
    "postinstall": "electron-builder install-app-deps"
},
@Rohithgilla12
Copy link

@hulxv Hey did you find any hack or workaround to this?
Thanks

@hulxv
Copy link
Author

hulxv commented Jan 9, 2022

@hulxv Hey did you find any hack or workaround to this?
Thanks

You can't export Html static pages when you use getServerSideProps.
So, You should use ipc communication between electron and frontend instead of that.

@hulxv hulxv closed this as completed Jan 10, 2022
@milton-imageline
Copy link

@hulxv could you elaborate a bit your last answer?

@hulxv
Copy link
Author

hulxv commented Jul 15, 2022

@hulxv could you elaborate a bit your last answer?

In electron js, there's a way to communicate between the main process and renderer process.
It's an inter-process communication.
You can send data from/to the main process to/from the renderer and make actions or events.
You can learn all of that from electron js documentation

@milton-imageline
Copy link

Hi @hulxv . Thanks for your quick reply!
My main concern here is the following: I thought that Nextron will behave like Next.js in terms of, for instance, revalidating the content of the pages each X minutes, but now it seems to me that once the build is done, pages will be exactly the same unless the user gets another build of the app. Is this correct?
Thanks again.

@hulxv
Copy link
Author

hulxv commented Jul 21, 2022

Hi @hulxv . Thanks for your quick reply!
My main concern here is the following: I thought that Nextron will behave like Next.js in terms of, for instance, revalidating the content of the pages each X minutes, but now it seems to me that once the build is done, pages will be exactly the same unless the user gets another build of the app. Is this correct?
Thanks again.

Sorry for late response.
Yes, that's correct.
Nextron just export nextjs pages on build time. So, you need update your app everytime when you change your page content (or renderer code).

@Willem-Jaap
Copy link
Contributor

To add a bit to this answer, you can have dynamic content, and probably want to. You just have to treat the renderer part of your application as a client-side javascript framework.

For functionality like serverside rendering, next needs a server. A static export of your Next application does not have this server, which means you can't use SSR.

You can use IPC in your frontend code to request data from your main process. In your main process you can get the data from a database or do a request to an external API.

Your entire application does not have to be static.

@milton-imageline
Copy link

Thank you both!

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

4 participants