Skip to content

[nextjs] Secured variants generation for server components in Design Studio#369

Open
yavorsk wants to merge 5 commits intodevfrom
feature/JSS-8846
Open

[nextjs] Secured variants generation for server components in Design Studio#369
yavorsk wants to merge 5 commits intodevfrom
feature/JSS-8846

Conversation

@yavorsk
Copy link
Contributor

@yavorsk yavorsk commented Feb 17, 2026

Description / Motivation

This PR enables and extends Design Studio's component generation features for server components in NexttJs app router application.

  • enables variant generation mode for server components;
  • now the application does not accept the generated code from design studio directly, via message event. Instead it makes a secured request to an endpoint where the generated component data is stored;
  • introduce separate default imports for server and client components for NextJs app router application

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate) - Design Studio with App router app and server side components

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 122.52 KB 122.52 KB ✅ 0.00 KB 100.00% 100.00% 0.00%
cli 58.70 KB 58.70 KB ✅ 0.00 KB 69.73% 69.73% 0.00%
content 397.02 KB 401.37 KB 🔺 +4.35 KB 92.35% 92.41% +0.06%
core 90.85 KB 90.85 KB ✅ 0.00 KB 91.82% 91.82% 0.00%
create-content-sdk-app 243.64 KB 243.64 KB ✅ 0.00 KB 96.22% 96.22% 0.00%
events 76.91 KB 76.91 KB ✅ 0.00 KB 98.40% 98.40% 0.00%
nextjs 430.10 KB 437.21 KB 🔺 +7.11 KB 89.75% 89.37% -0.38%
personalize 63.45 KB 63.45 KB ✅ 0.00 KB 99.32% 99.32% 0.00%
react 289.54 KB 290.11 KB 🔺 +0.57 KB 93.80% 93.86% +0.05%
search 7.11 KB 7.11 KB ✅ 0.00 KB 98.57% 98.57% 0.00%
Total 🔺 +12.03 KB

@illiakovalenko illiakovalenko changed the title [core] [react] [nextjs] Variant generation for server components in Design Studio follow up [core] [react] [nextjs] Secured Variant generation for server components in Design Studio Feb 18, 2026
@illiakovalenko illiakovalenko changed the title [core] [react] [nextjs] Secured Variant generation for server components in Design Studio [nextjs] Secured variants generation for server components in Design Studio Feb 18, 2026
Copy link
Collaborator

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

Looks good overall. Please see suggestions below for further refinement

}
);

if (componentDataResponse.status !== 200) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a mechanism for handling unsuccessful requests?

_updateServerComponentAction({ uid: component.uid!, previewComponent: eventArgs });
_updateServerComponentAction({
uid: component.uid!,
serverComponentPreviewEventArgs: eventArgs,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this property be simplified and renamed to eventArgs?
The method name itself already indicates that it operates within the server component scope.

Suggested change
serverComponentPreviewEventArgs: eventArgs,
eventArgs,

const generatedComponentData = await fetchGeneratedComponentFromCache(
componentUpdate.serverComponentPreviewEventArgs.message.cache.id,
componentUpdate.serverComponentPreviewEventArgs.message.cache.token,
process.env.SITECORE_EDGE_URL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's allow DesignLibraryApp to accept api property. You will be able to pass scConfig.api so you will have access to custom edge url as well. This is needed as well to support custom hostnames feature

Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed, can be read from "ClientEvents" component via "useSitecore"

* This enables dynamic rendering of server components inside Design Library
* @param {ComponentUpdateModel} componentUpdate - The component update model containing the UID and optional updated or preview component data.
* @returns A Promise that resolves when the cache has been updated.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would make sense to split this server action into two separate actions:

  • one dedicated to handling the update event,
  • another responsible for the initial preview.

This separation should reduce ambiguity and make the intent and flow easier to understand and maintain.

Some properties should be renamed to improve clarity and consistency.

In addition, ComponentUpdateModel appears to be handling multiple concerns and could be split into more focused models. This would make the structure easier to understand and maintain going forward.

@illiakovalenko
Copy link
Collaborator

@yavorsk Please, update Changelog as well

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

Successfully merging this pull request may close these issues.

2 participants