Learn how to quickly get started with Elements Dev Portal in a React project.
We've created a Create React App template, which allows you to create a brand new Elements Dev Portal website in React without any additional setup.
npx create-react-app my-dir --template @stoplight/elements-dev-portalThen run cd my-dir and yarn start and you will see a basic Elements Dev Portal website in the browser.
When the server has started, navigate to http://localhost:3000. There you will see Elements Dev Portal rendering an example Git project. Follow the instructions below to change your projectId and load up one of your own projects.
To install Elements Dev Portal in an existing React app, follow these instructions.
- Install the @stoplight/elements-dev-portal package with NPM/Yarn.
yarn add @stoplight/elements-dev-portal- In
App.jsimport the API component and CSS file from the Elements library.
import { StoplightProject } from '@stoplight/elements-dev-portal';
import '@stoplight/elements-dev-portal/styles.min.css';- Find the "Project ID" from the Project Settings view of your Stoplight Project.
Note: you will receive a ‘Forbidden’ error if the project visibility is not set to "Public"
Project Settings can only be viewed by Project Editors or above. Read more about project permissions here.
- Now you can replace the existing App component's contents with the StoplightProject component.
<StoplightProject projectId="INSERT_YOUR_PROJECT_ID_HERE" />Now your App.js file should look something like this:
import React from 'react';
import { StoplightProject } from '@stoplight/elements-dev-portal';
import '@stoplight/elements-dev-portal/styles.min.css';
function App() {
return (
<div className="App">
<StoplightProject projectId="INSERT_YOUR_PROJECT_ID_HERE" />
</div>
);
}
export default App;Now start the development server.
yarn startAnd you should see the API reference documentation for the Zoom API!
projectId- Find the Project ID in the Project Settings screen on Stoplight.platformUrl- By default this ishttps://stoplight.io/and this default will be fine for most people. Some enterprise customers might need to change it.basePath- Helps when usingrouter: 'history'but docs are in a subdirectory likehttps://example.com/docs/api.collapseTableOfContents- Passtrueto stop the table of contents expanding folders of articles, and showing lists of endpoints for an API. This will clean up the ToC if you have a lot of content.hideMocking- Passtrueto disable all mocking options and remove mention of the mock server.hideTryIt- Passtrueto hide the "Try It" panel (the interactive API console).router- Determines how navigation should work:history- (default) uses the HTML5 history API to keep the UI in sync with the URL.hash- uses the hash portion of the URL (i.e. window.location.hash) to keep the UI in sync with the URL.memory- keeps the history of your "URL" in memory (does not read or write to the address bar).static- renders using the StaticRouter which can help rendering pages on the server.
