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

"Server Actions" are not supported with Static Export #1312

Open
1 task done
zawadzki-dawid opened this issue Jan 9, 2025 · 9 comments
Open
1 task done

"Server Actions" are not supported with Static Export #1312

zawadzki-dawid opened this issue Jan 9, 2025 · 9 comments
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@zawadzki-dawid
Copy link

zawadzki-dawid commented Jan 9, 2025

Describe the issue you're facing

My team is facing an issue where storyblok SDK is blocking the static export of our application with message Server Actions are not supported with static export. I tried to downgrade the storyblok/react package to version 3.0.10 and it solved the issue. Can we opt out of using server actions with the latest package?

Edit:
I found out that StoryblokStory was using server actions under the hood, I replaced it with StoryblokServerComponent but build is still failing. Is tree-shaking not working with the package?

Screenshot 2025-01-09 at 20 55 40

Reproduction

NA

Steps to reproduce

  • Add to { "output": "export" } to next.config.js
  • Use SDK somewhere in code
  • Build next app

System Info

"@storyblok/react": "^4.0.0"
"next": "14.12.16"
"react": "18.3.1"

Used Package Manager

pnpm

Error logs (Optional)

No response

Validations

@zawadzki-dawid zawadzki-dawid added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jan 9, 2025
@kelkes
Copy link

kelkes commented Jan 13, 2025

👍

Same issue here. Tried to replace <StoryblokStory /> with <StoryblokServerComponent /> too. Didn't work.

As the Server Actions is used for live editing (as far as I understand this), an option to disable that would be great for static export.

I know you've got plenty to do right now... but this is kinda blocking my projects right now. :(

@zawadzki-dawid
Copy link
Author

I recommend going version down to 3.0.10, but probably like in our case you must have this thread on mind :) #952

@kelkes
Copy link

kelkes commented Jan 14, 2025

I recommend going version down to 3.0.10, but probably like in our case you must have this thread on mind :) #952

That could be an option, but results in rewriting parts of the website... :(

@filmic
Copy link

filmic commented Jan 15, 2025

Workaround:

  • edit and remove "use server"; from these files:
    • node_modules/@storyblok/react/dist/live-edit-update-action.mjs
    • node_modules/@storyblok/react/dist/live-edit-update-action.js
  • remove .next folder to clear build cache
  • run npm run build

@kelkes
Copy link

kelkes commented Jan 15, 2025

Thanks!

That only works locally though... but I run the build as GitHub Action. :(

@filmic
Copy link

filmic commented Jan 15, 2025

Try to add it as a step in GitHub Action job (after installing dependencies but before building)

- name: Remove 'use server' directive
  run: |
    sed -i 's/"use server";//g' node_modules/@storyblok/react/dist/live-edit-update-action.mjs
    sed -i 's/"use server";//g' node_modules/@storyblok/react/dist/live-edit-update-action.js

Edit: corrected sed commands

@kelkes
Copy link

kelkes commented Jan 15, 2025

@filmic ah! thats a good idea. thanks

@zawadzki-dawid
Copy link
Author

Thanks for workaround @filmic 🙌

@Simon-Hayden-Dev
Copy link

An alternative to @filmic's approach would be to use patch-package. That way all devs have the same code-base and can build locally as well.

For pnpm there is pnpm patch - no dependency needed. Same with yarn patch, but I've never used it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

4 participants