Once you've gotten your CLI set up, you can use our sandbox web-app to test out syncing text from Ditto directly into development with a real web-app. After this, you'll have the same setup we have in our demo video!
A Ditto account — with either Admin or Editor permissions
A locally installed Ditto CLI
A Figma account — don't worry, you don't need to be an expert Figma user! Our sample Figma file has got you covered. You just need a Figma account in order to import the text into Ditto.
In order to have a project you can pull from with our CLI, you'll have to create a project in Ditto. At the moment, Ditto projects are created by linking and importing text from a Figma file.
Don't worry, we've made a sample Figma file that corresponds with our example web-app!
Duplicate our sample Figma file, Dittobnb.
Import it into Ditto. To match up with our sandbox web-app, you should import all of the frames in the file. For instructions on importing a file to Ditto, click here.
You should now be able to see your new Ditto project in your workspace. We'll come back to this in a bit!
Our sandbox web-app is a simple React application that mirrors what's contained in the Dittobnb Figma file. To get it set up:
Duplicate the sandbox repo
npm start to run the web-app locally
A couple of things to note:
The web-app is currently displaying text from
/ditto/text.json, which we have preloaded into the repo. Once you set up the CLI with the web-app, it'll overwrite this file with text from your actual project.
Our web-app is also set up with our React SDK. You can see it in action in each of the React components in
Now that you've got both the Ditto project and web-app, let's link the two so that changes you make in the Ditto project (or Figma file!) can be pulled directly into development.
Structure your Ditto project to match
Because the pre-loaded JSON in the repo was generated to from a Ditto project, you'll have to organize your project a bit so that it matches the JSON. Don't worry, you won't have to do this for other projects (aka without a pre-loaded JSON)!
In the Ditto web-app, create blocks in the project for:
Text in the nav bar
Text in the Hero
Columns of the footer
You can also refer directly to
/ditto/text.json to see the structure of the sample JSON (and the blocks that are set up there). For help creating blocks, click here.
Turn on Developer Mode in the project.
For help with turning on Developer mode, click here.
Rename or replace IDs.
At the moment, the web-app front-end fetches specific frames/blocks/texts via IDs provided to the React SDK. In order for it to continue working once you link up the CLI (which replaces the
text.json with the real JSON generated from your project), you'll have to either:
Rename the IDs in your project to match the ones used in the front-end.
OR, replace the ID's given to the React SDK with the real ones from your project.
You can also do a combination of the two, as long as the project matches how it's referenced in development. Note that this is also a step you don't have to do if you're starting a project from scratch!
Link the CLI.
In the terminal, navigate to the root of the project repository.
Use the command
ditto-cli project, and select the Dittobnb project from the list. Note that this command will only list projects that have Developer Mode turned on.
To pull in text from your actual Ditto project (and replace the
text.json in your local directory), use the command
ditto-cli pull. You may have to check back on your web-app to see if there are any missing or incorrect IDs.
A couple of things you can try include:
Editing in Ditto or Figma, and then doing a
ditto-cli pull. All you have to do is refresh the web-app to see the latest copy changes pulled in. Magic!
/listing page of the web-app, we've left some text items from the mockup out of the web-app. Try and see if you can implement new pieces of text into the web-app!