For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

JavaScript

Use Frakment in a plain JavaScript project without TypeScript.

Frakment components ship as TypeScript. To use them in a plain JavaScript project, strip type annotations after install. This page covers which patterns to strip, how to strip them, and what stays.

Prerequisites

  • A JavaScript project (.jsx / .js)
  • React 19
  • Tailwind CSS v4

Setup

Run init and add a component as usual:

$ npx frakment@latest init
npx frakment@latest add button

The CLI writes .tsx. Rename to .jsx and strip types.

Stripping types

Frakment uses four TypeScript patterns. Remove them in this order:

PatternStrip to
interface Props { ... }Delete the entire block
(props: Props)(props)
React.ComponentProps<"div">{} (empty object)
as constDelete as const

Example

A typical Frakment component has a props interface, a ComponentProps generic, and a cva call. Strip all three:

button.tsx (before)
interface ButtonProps extends React.ComponentProps<"button"> {
  variant?: "default" | "outline";
  size?: "sm" | "md";
}
 
export function Button({ variant = "default", size = "md", ...props }: ButtonProps) {
  return <button data-variant={variant} data-size={size} {...props} />;
}
button.jsx (after)
export function Button({ variant = "default", size = "md", ...props }) {
  return <button data-variant={variant} data-size={size} {...props} />;
}

Components with more types

Compound components use more patterns. Here is a Dialog example. The first snippet is the typed source; the second is the same component with JavaScript types stripped.

TypeScript:

tsx
function DialogContent({
  className,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Content>) {
  return <DialogPrimitive.Content className={className} {...props} />;
}

JavaScript:

tsx
function DialogContent({ className, ...props }) {
  return <DialogPrimitive.Content className={className} {...props} />;
}
button.jsx (after)
export function Button({ variant = "default", size = "md", ...props }) {
  return <button data-variant={variant} data-size={size} {...props} />;
}

Components with more types

Compound components use more patterns. Here is a Dialog example:

TypeScript:

tsx
function DialogContent({
  className,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Content>) {
  return <DialogPrimitive.Content className={className} {...props} />;
}

JavaScript:

tsx
function DialogContent({ className, ...props }) {
  return <DialogPrimitive.Content className={className} {...props} />;
}

Engine packages

@frakment/ai ships compiled JavaScript with .d.ts types. They work in JS projects without any changes. Keep the .d.ts files — your editor uses them for hints even in a JS project.

Common errors

A type annotation is still present. Search for : React. and : Props in the .jsx file.

class-variance-authority exports VariantProps as a type only. In JavaScript, remove the import and the type annotation. cva() itself works in JS.

Best practices

  • Keep .d.ts files. Import them for editor hints even in JS projects.
  • Do not edit installed TSX in place. Copy to .jsx first, then edit.
  • Upgrade carefully. Re-running npx frakment add writes .tsx again — keep your .jsx in sync or run the CLI with --overwrite carefully.

Next