Documentation
Feedback
Guides
Storefront Development

Storefront Development
Store Framework
Using components
Using Sandbox blocks

Introduction

VTEX Store Framework is a very powerful tool meant to attend most client needs. It's understandable, though, that some custom requirements that your store needs and will not be served by the framework. That's where the Sandbox App comes in.

The Sandbox App is basically a component that supports iFrames. Therefore, it allows you to use custom html, css and js code to customize your store.

Step by step

  1. Go ahead and open your manifest.json file and declare the Sandbox app as a dependency.

{"base64":"  ","img":{"width":1026,"height":944,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":134601,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-io-documentation-using-sandbox-blocks-0.png"}}

  1. Then, declare the Sandbox block in the blocks folder or in the blocks.jsonc file.

_10
"sandbox#h1": {
_10
"props": {
_10
"width": "100%",
_10
"height": "auto",
_10
"initialContent": "<h1 style=\"text-align:center;\">Hello World</h1>",
_10
"allowCookies": false
_10
}
_10
}

Let's suppose you want to create a simple h1 sandbox block. It would look similar to the following:

{"base64":"  ","img":{"width":1600,"height":1210,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":455279,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-io-documentation-using-sandbox-blocks-1.png"}}

  1. Reference it in another's block child dependency or blocks. For instance, your store.home:

_13
//home.jsonc
_13
"store.home": {
_13
"blocks": [
_13
"carousel#home",
_13
"sandbox#h1",
_13
"flex-layout.row#deals",
_13
"shelf#home",
_13
"info-card#home",
_13
"rich-text#question",
_13
"rich-text#link",
_13
"newsletter"
_13
]
_13
},

That should render the h1 sandbox on the store's page!

Best Practices

If you think that a component is very similar to what will serve your store needs but that it still needs some tweaks, you should find the right style and props to turn into the custom component you are looking for.

Sandbox should only be used whenever Store Framework native components won't handle your scenario and when what you intend to do is simple enough that it doesn't require a lot of outsource data. Creating everything using iFrames will make your store easily obsolete to new Store Framework features and not very good in terms of performance.

Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
On this page