{"id":20410,"library":"prettier-plugin-react","title":"Prettier Plugin React","description":"Prettier plugin for React (v0.0.1, experimental). Reformats JSX/TSX with custom options. Not yet stable; limited adoption. Differentiates by providing React-specific formatting beyond built-in Prettier JSX support.","status":"active","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/nrjdalal/prettier-plugin-react","tags":["javascript","prettier","plugin","react","typescript"],"install":[{"cmd":"npm install prettier-plugin-react","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-react","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-react","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; no CJS support.","wrong":"const prettierPluginReact = require('prettier-plugin-react')","symbol":"default","correct":"import prettierPluginReact from 'prettier-plugin-react'"},{"note":"Named export for plugin options object.","wrong":"","symbol":"options","correct":"import { options } from 'prettier-plugin-react'"},{"note":"TypeScript: use `import type` to avoid runtime import.","wrong":"import { Plugin } from 'prettier-plugin-react'","symbol":"Plugin","correct":"import type { Plugin } from 'prettier-plugin-react'"}],"quickstart":{"code":"import prettier from 'prettier';\nimport prettierPluginReact from 'prettier-plugin-react';\n\nconst code = `const App = () => <div>Hello</div>;`;\n\nprettier.format(code, {\n  parser: 'babel',\n  plugins: [prettierPluginReact],\n  jsxSingleQuote: true,\n}).then(result => console.log(result));\n// Output: const App = () => <div>Hello</div>;\n","lang":"typescript","description":"Shows how to use the plugin with Prettier API to format JSX code with custom options."},"warnings":[{"fix":"Use Prettier v2.x or check compatibility.","message":"Plugin may not work with Prettier v3+","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Pin to exact version and test upgrades.","message":"No stable release; API may change","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use dynamic import or ESM project.","message":"ESM-only; no CommonJS bundle","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import prettierPluginReact from 'prettier-plugin-react'` or dynamic import.","cause":"Using CommonJS require() on ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported."},{"fix":"Ensure plugin is imported and passed in `plugins` array when calling prettier.format.","cause":"Plugin not included in plugins array or wrong import.","error":"TypeError: prettierPluginReact is not a plugin"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}