
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-apiembed
Advanced tools
React components encapsulating functionality of apiembed. Allows you to generate code snippets from HARs, all in the browser, with the power of react. Examples
Built with:
React components included
<CodeSnippet .../>
- Render a code snippet from a HAR.<CodeSnippetWidget .../>
- Tabbed UI for selecting languages to render individual CodeSnippet
s<Apiembed .../>
- WIPyarn install
# or
npm install
Using as a ES module:
import React from "react"
import { render } from "react-dom"
import { CodeSnippet, CodeSnippetWidget } from "react-apiembed"
class MyApp extends React.Component {
render() {
const har = {
method: "POST",
url: "http://mockbin.com/request",
httpVersion: "HTTP/1.1",
queryString: [{ name: "foo", value: "bar" }, { name: "foo", value: "baz" }],
headers: [
{ name: "Accept", value: "application/json" },
{ name: "Content-Type", value: "application/json" }
],
cookies: [{ name: "foo", value: "bar" }, { name: "bar", value: "baz" }],
postData: { mimeType: "application/json", text: '{"foo": "bar"}' }
}
return (
<div>
<CodeSnippet har={har} prismLanguage="javascript" target="javascript" client="jquery" />
<CodeSnippetWidget
har={har}
snippets={[
{
prismLanguage: "go",
target: "go"
},
{
prismLanguage: "bash",
target: "shell",
client: "curl"
}
]}
/>
</div>
)
}
}
render(<MyApp />, document.getElementById("root"))
<CodeSnippet/>
Name | Required | Default | Type | Description |
---|---|---|---|---|
har | ✔ | Object | HAR Request object as outlined here | |
prismLanguage | ✔ | String | Prism languages. Currently supports: bash , javascript , php , go , ruby , ocaml , ruby , java , python , swift , csharp , clike | |
target | ✔ | String | httpsnippet target prop e.g. "node", "javascript", "shell", "go" etc. | |
client | null | String | httpsnippet client prop. e.g. "xhr", "curl" etc. |
<CodeSnippetWidget/>
Name | Required | Type | Description |
---|---|---|---|
har | ✔ | Object | HAR Request object as outlined here |
snippets | ✔ | Object | Array of snippet objects |
snippet
properties
Name | Required | Default | Type | Description |
---|---|---|---|---|
prismLanguage | ✔ | String | Prism languages. See above for supported languages. | |
target | ✔ | String | httpsnippet target prop e.g. "node", "javascript", "shell", "go" etc. | |
client | null | String | httpsnippet client prop. e.g. "xhr", "curl" etc. |
npm run test
FAQs
React api embed component.
The npm package react-apiembed receives a total of 127 weekly downloads. As such, react-apiembed popularity was classified as not popular.
We found that react-apiembed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.