Skip to content

Fix custom components in SSR Mode + Custom Component Examples#12566

Merged
freddyaboulton merged 12 commits intomainfrom
load-custom-components-ssr-mode
Mar 17, 2026
Merged

Fix custom components in SSR Mode + Custom Component Examples#12566
freddyaboulton merged 12 commits intomainfrom
load-custom-components-ssr-mode

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Dec 15, 2025

Description

  • Fix custom components in SSR mode. Problem was that in SSR mode, the component_loader was requesting an import via http which node can't handle. In the server, we load the @gradio/fallback and then load the real component in the client. We had this behavior in 5.0.
  • Fix custom component examples. There were two problems. First, the example file was being compiled to example.js but component_loader expects index.js. So just modified @gradio/preview to always output index.js in compilation. Second issue was that the Dataset component was loading components with the host app runtime but we need to use the custom component runtime. Followed a similar approach to MountCustomComponent in js/core.

To test:

  • Install the wheel from this pr
  • Create a custom component. I tested with image component.
  • Build the custom component.
  • Uncomment the examples line in the generated app.py.
  • Run app.py in both ssr and spa modes.

AI Disclosure

We encourage the use of AI tooling in creating PRs, but the any non-trivial use of AI needs be disclosed. E.g. if you used Claude to write a first draft, you should mention that. Trivial tab-completion doesn't need to be disclosed. You should self-review all PRs, especially if they were generated with AI.

  • I used AI to investigate why ssr was not working
  • I did not use AI

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented Dec 15, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/968acbd3a3a5cb02c3b533b011c0a6048b597d10/gradio-6.9.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@968acbd3a3a5cb02c3b533b011c0a6048b597d10#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/968acbd3a3a5cb02c3b533b011c0a6048b597d10/gradio-client-2.1.0.tgz

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented Dec 15, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/chatbot patch
@gradio/core patch
@gradio/dataset patch
@gradio/preview patch
@gradio/utils patch
@self/build patch
gradio patch

  • Fix custom components in SSR Mode + Custom Component Examples

✅ Changeset approved by @freddyaboulton

  • Maintainers can remove approval by unchecking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@freddyaboulton freddyaboulton added the v: patch A change that requires a patch release label Dec 16, 2025
@freddyaboulton freddyaboulton added the t: fix A change that implements a fix label Dec 16, 2025
@freddyaboulton freddyaboulton force-pushed the load-custom-components-ssr-mode branch from e4fe630 to 1b0e7f6 Compare March 13, 2026 19:55
@freddyaboulton freddyaboulton requested a review from pngwn March 16, 2026 20:58
@freddyaboulton freddyaboulton marked this pull request as ready for review March 16, 2026 21:00
Copy link
Copy Markdown
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks @freddyaboulton!

@freddyaboulton
Copy link
Copy Markdown
Collaborator Author

tysm @pngwn !

@freddyaboulton freddyaboulton merged commit 7760161 into main Mar 17, 2026
26 of 32 checks passed
@freddyaboulton freddyaboulton deleted the load-custom-components-ssr-mode branch March 17, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t: fix A change that implements a fix v: patch A change that requires a patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants