Skip to content
RapiDocv11.0
GitHub

Quickstart & Framework Integration

RapiDoc is packaged as a standard W3C Web Component (Custom Element). This means it runs natively across all modern browsers and can be integrated into virtually any web framework without specialized wrappers or adapters.


Add the ES module script tag inside the <head> of your HTML document:

<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>

The simplest way to use RapiDoc is by embedding the <rapi-doc> tag directly in your markup:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>API Documentation</title>
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
rapi-doc {
width: 100vw;
height: 100vh;
display: block;
}
</style>
</head>
<body>
<rapi-doc
spec-url="https://petstore.swagger.io/v2/swagger.json"
color-scheme="dark"
render-style="read"
show-header="true"
allow-try="true"
></rapi-doc>
</body>
</html>

Because Custom Elements are a standard browser feature, they seamlessly accept attributes and properties in modern web frameworks.

In React 18 and Next.js (App Router), Custom Elements must be loaded exclusively on the client side since browsers execute Web Component definitions in client DOM.

import React, { useEffect, useState } from 'react';
export default function ApiDocs() {
const [mounted, setMounted] = useState(false);
useEffect(() => {
// Dynamic import ensures Web Component executes in browser environment
import('rapidoc');
setMounted(true);
}, []);
if (!mounted) return <div>Loading API Documentation...</div>;
return (
<div style={{ width: '100vw', height: '100vh' }}>
{/* @ts-ignore custom element JSX declaration */}
<rapi-doc
spec-url="https://petstore.swagger.io/v2/swagger.json"
color-scheme="dark"
render-style="view"
show-header="false"
style={{ width: '100%', height: '100%', display: 'block' }}
/>
</div>
);
}

Vue provides first-class support for Custom Elements. Tell Vue compiler to treat <rapi-doc> as a custom element rather than a missing Vue component:

vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
// Tell Vue to ignore custom element tags starting with 'rapi-'
isCustomElement: (tag) => tag.startsWith('rapi-'),
},
},
}),
],
});

In Angular, add CUSTOM_ELEMENTS_SCHEMA to your module or standalone component:

import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import 'rapidoc';
@Component({
selector: 'app-api-docs',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<rapi-doc
spec-url="https://petstore.swagger.io/v2/swagger.json"
color-scheme="dark"
render-style="view"
style="height: 100vh; width: 100%; display: block;">
</rapi-doc>
`,
})
export class ApiDocsComponent {}

Here are the most frequently used attributes when initializing RapiDoc:

Attribute Type Default Description
spec-url string "" URL of the OpenAPI / Swagger JSON or YAML specification.
theme string "amber" Theme palette preset (amber, blue, emerald, violet, rose, graphite, slate) or custom #hex.
color-scheme string "dark" Color mode: 'dark', 'light', or 'system'.
radius string "sm" Corner radius: 'none', 'sm', 'md', 'lg', or 'full'.
scale string "default" Global UI scale: 'sm', 'default', or 'lg'.
render-style string "view" Layout mode: 'read', 'view', or 'focused'.
show-header boolean true Displays the top navigation bar with search, server selection, and auth controls.
allow-try boolean true Allows developers to execute interactive API requests directly from the UI.
allow-authentication boolean true Shows security and API key authentication panels.