Skip to content

@kubb/react 🦙under construction ​

Use React to create templates/variants for any plugin.


Installation ​

shell
bun add @kubb/react
bun add @kubb/react
shell
pnpm add @kubb/react
pnpm add @kubb/react
shell
npm install @kubb/react
npm install @kubb/react
shell
yarn add @kubb/react
yarn add @kubb/react

Configure tsconfig.json ​

json
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@kubb/react" 
  }
}
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@kubb/react" 
  }
}

Examples ​

Text ​

tsx
import { createRoot, Text } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Text>
     export const test = 2;
    </File>
  )
}

root.render(<Component />)

return root
import { createRoot, Text } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Text>
     export const test = 2;
    </File>
  )
}

root.render(<Component />)

return root
typescript
export const test = 2
export const test = 2

Text with indent ​

tsx
import { createRoot, Text } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Text indentSize={2}>
     export const test = 2;
    </File>
  )
}

root.render(<Component />)

return root
import { createRoot, Text } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Text indentSize={2}>
     export const test = 2;
    </File>
  )
}

root.render(<Component />)

return root
typescript
export const test = 2
export const test = 2

Function ​

tsx
import { createRoot, Function } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Function name="getData" export async>
      return 2;
    </Function>
  )
}

root.render(<Component />)

return root
import { createRoot, Function } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <Function name="getData" export async>
      return 2;
    </Function>
  )
}

root.render(<Component />)

return root
typescript
export async function getData() {
  return 2
}
export async function getData() {
  return 2
}

File ​

tsx
import { createRoot, File } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <File baseName="test.ts" path="path">
      <File.Import name={'React'} path="react" print />
    </File>
  )
}

root.render(<Component />)

return root
import { createRoot, File } from '@kubb/react'

const root = createRoot()

const Component = () => {
  return (
    <File baseName="test.ts" path="path">
      <File.Import name={'React'} path="react" print />
    </File>
  )
}

root.render(<Component />)

return root
typescript
export function test() {
  return true
}
export function test() {
  return true
}

Released under the MIT License.