Plugin Installation
Swytchcode provides a powerful React-based plugin that can be embedded into your applications or portals, allowing developers to test, generate, and explore API methods/workflows interactively. It also provides an interface to manage the developers’ MCP access
Prerequisites
- Before installing the plugin, make sure you create a project in your Swytchcode dashboard
- Upload one or more libraries (OpenAPI, Postman collection, or SDK) to that project
- Copy the project’s API key, which is required to initialize the plugin
🔑 Note: The API key is scoped at the project level and will automatically expose all libraries within that project to the plugin.
React Installation
- Install Swytchcode Using npm:
npm install swytchcode
Or using yarn:
yarn add swytchcode
- Add the Plugin to Your Code Here’s a minimal example using React:
import 'swytchcode/dist/style.css';import { Swytchcode } from 'swytchcode';
function App() { return ( <div style={{ width: '100vw', minHeight: '100vh' }}> <Swytchcode apiBaseUrl="https://api-v2.swytchcode.com" projectApiKey="<API_KEY>" show_mcp={true} // Set to false to hide MCP panel and menu /> </div> );}
export default App;
Notes
- CSS Import Required: Don’t forget to import the Swytchcode CSS file (swytchcode/dist/style.css).
- Full-Screen Display: Wrap the plugin in a container with width: 100vw and minHeight: 100vh to ensure full-page coverage.
- React Version: Swytchcode uses react and react-dom version ^18.3.1. If your app uses a different React version, you may encounter version conflicts. Please align with the recommended version where possible.
Alternative installation
Swytchcode also supports legacy iframe-based embedding, which is useful for non-React environments or low-code platforms. Note that iframe usage may incur additional hosting costs depending on your plan.
Platform-Specific Examples
We maintain an open-source repository with working plugin examples for various platforms (React, Next.js, Mintlify, etc.): https://github.com/Swytchcode/plugin-installation-examples