I created an item TestComponent-1 under my Test route.

sitecore tree

This is the display of my TestComponent-1

test route

Now I navigate to my Test2 route through experience editor and add TestComponent-1 item. This is the result

test2 route

My question is : Can we reuse item in different routes?

  • If yes : How to do it?
  • If no : Why I was able to add TestComponent-1 to Test2 route without any errors? The behavior I expected was that the TestComponent-1 moved from Test route to Test2 route

Maybe there is a key concept that I didn't understand, if so please explain



You can share content between components using ID references.

These let you:

  • Assign a unique ID to a piece of shared content (in component-content or content, usually)
  • Refer to that ID from another piece of content, as a datasource or referenced item

Here's an example of referring to content by ID in the Angular sample: https://github.com/Sitecore/jss/blob/cda6450b024d8fa801f88d0dac31ab335ab9ec06/samples/basic-sample-angular/data/routes/en.yaml#L31

And defining the content by ID: https://github.com/Sitecore/jss/blob/cda6450b024d8fa801f88d0dac31ab335ab9ec06/samples/basic-sample-angular/data/component-content/Welcome/SharedWelcome/en.yaml#L2

This assumes you're working in disconnected mode and importing the app to Sitecore. If you're defining your items within Sitecore, then there's nothing special JSS-wise and you can refer to datasource items from anywhere.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.