{"id":8375,"date":"2024-11-27T09:38:17","date_gmt":"2024-11-27T04:08:17","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8375"},"modified":"2024-11-27T09:38:22","modified_gmt":"2024-11-27T04:08:22","slug":"building-a-reusable-react-component-library-with-typescript","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/","title":{"rendered":"Building a Reusable React Component Library with TypeScript"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Step 1: Create the Project Directory and Files<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Inside the src folder of your project, create a directory named Components.<\/li>\n\n\n\n<li>In the Components directory, add a file named PheonixSnackbar.tsx.<\/li>\n\n\n\n<li>Create an index.ts file in the src directory with the following content:\n<ul class=\"wp-block-list\">\n<li> export { default as PheonixSnackbar } from &#8216;.\/Components\/PheonixSnackbar&#8217;;<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><br>It should look something like this\u00a0<br><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"164\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\"><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Install Required Dependencies<\/strong><\/h3>\n\n\n\n<p>Install the essential dependencies, including React, TypeScript, and tslib, by running:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>npm install react typescript @types\/react tslib &#8211;save-dev<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Configure TypeScript<\/strong><\/h3>\n\n\n\n<p>Generate a tsconfig.json file with default configurations:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>npx tsc &#8211;init<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Next, update tsconfig.json with the following configuration:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>{<br>&nbsp; &#8220;compilerOptions&#8221;: {<br>&nbsp; &nbsp; &#8220;target&#8221;: &#8220;es5&#8221;,<br>&nbsp; &nbsp; &#8220;lib&#8221;: [&#8220;dom&#8221;, &#8220;dom.iterable&#8221;, &#8220;esnext&#8221;],<br>&nbsp; &nbsp; &#8220;allowJs&#8221;: true,<br>&nbsp; &nbsp; &#8220;skipLibCheck&#8221;: true,<br>&nbsp; &nbsp; &#8220;esModuleInterop&#8221;: true,<br>&nbsp; &nbsp; &#8220;allowSyntheticDefaultImports&#8221;: true,<br>&nbsp; &nbsp; &#8220;strict&#8221;: true,<br>&nbsp; &nbsp; &#8220;forceConsistentCasingInFileNames&#8221;: true,<br>&nbsp; &nbsp; &#8220;noFallthroughCasesInSwitch&#8221;: true,<br>&nbsp; &nbsp; &#8220;module&#8221;: &#8220;esnext&#8221;,<br>&nbsp; &nbsp; &#8220;moduleResolution&#8221;: &#8220;node&#8221;,<br>&nbsp; &nbsp; &#8220;resolveJsonModule&#8221;: true,<br>&nbsp; &nbsp; &#8220;isolatedModules&#8221;: true,<br>&nbsp; &nbsp; &#8220;noEmit&#8221;: true,<br>&nbsp; &nbsp; &#8220;jsx&#8221;: &#8220;react-jsx&#8221;<br>&nbsp; },<br>&nbsp; &#8220;include&#8221;: [&#8220;src&#8221;]<br>}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Set Up Rollup for Bundling<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>npm install rollup &#8211;save-dev<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install additional Rollup plugins for TypeScript and common tasks:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>npm install @rollup\/plugin-node-resolve @rollup\/plugin-commonjs @rollup\/plugin-typescript rollup-plugin-peer-deps-external @rollup\/plugin-terser rollup-plugin-dts &#8211;save-dev<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Configure Package Output in <\/strong><strong>package.json<\/strong><\/h3>\n\n\n\n<p>Add the following fields to your package.json to specify the entry points for your package:<\/p>\n\n\n\n<p>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&#8220;main&#8221;: &#8220;dist\/index.js&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&#8220;module&#8221;: &#8220;dist\/index.mjs&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&#8220;types&#8221;: &#8220;dist\/index.d.ts&#8221;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Create <\/strong><strong>rollup.config.js<\/strong><strong> File<\/strong><\/h3>\n\n\n\n<p>In your project root, create a rollup.config.js file with the following content:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>import resolve from &#8220;@rollup\/plugin-node-resolve&#8221;;<br>import commonjs from &#8220;@rollup\/plugin-commonjs&#8221;;<br>import typescript from &#8220;@rollup\/plugin-typescript&#8221;;<br>import dts from &#8220;rollup-plugin-dts&#8221;;<br>import terser from &#8220;@rollup\/plugin-terser&#8221;;<br>import peerDepsExternal from &#8220;rollup-plugin-peer-deps-external&#8221;;<br><br>const packageJson = require(&#8220;.\/package.json&#8221;);<br><br>export default [<br>&nbsp; {<br>&nbsp; &nbsp; input: &#8220;src\/index.ts&#8221;,<br>&nbsp; &nbsp; output: [<br>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; file: packageJson.main,<br>&nbsp; &nbsp; &nbsp; &nbsp; format: &#8220;cjs&#8221;,<br>&nbsp; &nbsp; &nbsp; &nbsp; sourcemap: true,<br>&nbsp; &nbsp; &nbsp; },<br>&nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; file: packageJson.module,<br>&nbsp; &nbsp; &nbsp; &nbsp; format: &#8220;esm&#8221;,<br>&nbsp; &nbsp; &nbsp; &nbsp; sourcemap: true,<br>&nbsp; &nbsp; &nbsp; },<br>&nbsp; &nbsp; ],<br>&nbsp; &nbsp; plugins: [<br>&nbsp; &nbsp; &nbsp; peerDepsExternal(),<br>&nbsp; &nbsp; &nbsp; resolve(),<br>&nbsp; &nbsp; &nbsp; commonjs(),<br>&nbsp; &nbsp; &nbsp; typescript({ tsconfig: &#8220;.\/tsconfig.json&#8221; }),<br>&nbsp; &nbsp; &nbsp; terser(),<br>&nbsp; &nbsp; ],<br>&nbsp; &nbsp; external: [&#8220;react&#8221;, &#8220;react-dom&#8221;],<br>&nbsp; },<br>&nbsp; {<br>&nbsp; &nbsp; input: &#8220;src\/index.ts&#8221;,<br>&nbsp; &nbsp; output: [{ file: packageJson.types }],<br>&nbsp; &nbsp; plugins: [dts.default()],<br>&nbsp; },<br>];<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 7: Add a Build Script to <\/strong><strong>package.json<\/strong><\/h3>\n\n\n\n<p>Add the following script to your package.json to simplify building the package:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>{<br>&nbsp; &#8220;scripts&#8221;: {<br>&nbsp; &nbsp; &#8220;rollup&#8221;: &#8220;rollup -c &#8211;bundleConfigAsCjs&#8221;<br>&nbsp; }<br>}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 8: Build the Package<\/strong><\/h3>\n\n\n\n<p>Run the build script:<\/p>\n\n\n\n<p>npm run rollup<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 9: Link the Package for Local Testing<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the working directory, link the package locally:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yarn link<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>In the target project, use the linked package by running:<br>yarn link &lt;package-name&gt;<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 10: Resolve React Duplicates (if needed only)<\/strong><\/h3>\n\n\n\n<p>If you encounter errors related to duplicate React instances, remove duplicates with this command:<\/p>\n\n\n\n<p><strong>In MAC&nbsp;<\/strong><\/p>\n\n\n\n<p>rm -rf node_modules\/react node_modules\/react-dom<\/p>\n\n\n\n<p><strong>In Windows [Try both]<\/strong><\/p>\n\n\n\n<p>rd \/s \/q node_modules\\react<\/p>\n\n\n\n<p>rd \/s \/q node_modules\\react-dom<\/p>\n\n\n\n<p>Remove-Item -Recurse -Force .\\node_modules\\react<\/p>\n\n\n\n<p>Remove-Item -Recurse -Force .\\node_modules\\react-dom<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 11 : Publish the NPM&nbsp;<\/strong><\/h3>\n\n\n\n<p><strong>Sign Up for NPM<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to<a href=\"https:\/\/www.npmjs.com\/signup\"> npmjs.com\/signup<\/a> and create a new account.<\/li>\n\n\n\n<li>Verify your email if required.<\/li>\n<\/ul>\n\n\n\n<p><strong>Login to NPM in Terminal<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open your terminal (or Visual Studio Code terminal).<\/li>\n<\/ul>\n\n\n\n<p>Run the following command to log in to your NPM account:<\/p>\n\n\n\n<p><br><strong>npm login<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This will prompt you to:<\/li>\n<\/ul>\n\n\n\n<p>Enter your NPM <strong>username<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enter your <strong>password<\/strong>.<\/li>\n\n\n\n<li>Provide your <strong>email address<\/strong> associated with the account.<\/li>\n<\/ul>\n\n\n\n<p><strong>Publish the Package<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the comment to publish the package<br>npm publish<\/li>\n<\/ul>\n\n\n\n<p><strong>Success Confirmation<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After publishing, you will see a success message.<\/li>\n\n\n\n<li>Your package is now live on the NPM registry and can be installed using:<br><br>npm install &lt;package-name&gt;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Create the Project Directory and Files It should look something like this\u00a0 Step 2: Install Required Dependencies Install the essential dependencies, including React, TypeScript, and tslib, by running: npm install react typescript @types\/react tslib &#8211;save-dev Step 3: Configure TypeScript Generate a tsconfig.json file with default configurations: npx tsc&hellip; <a href=\"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">Building a Reusable React Component Library with TypeScript<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":507,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-8375","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"h-entry","9":"h-as-article"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pheonix Solutions - We Empower Your Business Growth<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pheonix Solutions - We Empower Your Business Growth\" \/>\n<meta property=\"og:description\" content=\"Step 1: Create the Project Directory and Files It should look something like this\u00a0 Step 2: Install Required Dependencies Install the essential dependencies, including React, TypeScript, and tslib, by running: npm install react typescript @types\/react tslib &#8211;save-dev Step 3: Configure TypeScript Generate a tsconfig.json file with default configurations: npx tsc&hellip; Continue Reading Building a Reusable React Component Library with TypeScript\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/\" \/>\n<meta property=\"og:site_name\" content=\"PHEONIXSOLUTIONS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-27T04:08:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-27T04:08:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\" \/>\n<meta name=\"author\" content=\"bharat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:site\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"bharat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/\"},\"author\":{\"name\":\"bharat\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/5e146ea8682be704a2553a73c97c786b\"},\"headline\":\"Building a Reusable React Component Library with TypeScript\",\"datePublished\":\"2024-11-27T04:08:17+00:00\",\"dateModified\":\"2024-11-27T04:08:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/\"},\"wordCount\":670,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/lh7-rt.googleusercontent.com\\\/docsz\\\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/\",\"name\":\"Pheonix Solutions - We Empower Your Business Growth\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/lh7-rt.googleusercontent.com\\\/docsz\\\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\",\"datePublished\":\"2024-11-27T04:08:17+00:00\",\"dateModified\":\"2024-11-27T04:08:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/lh7-rt.googleusercontent.com\\\/docsz\\\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\",\"contentUrl\":\"https:\\\/\\\/lh7-rt.googleusercontent.com\\\/docsz\\\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/building-a-reusable-react-component-library-with-typescript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building a Reusable React Component Library with TypeScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"name\":\"Pheonix Solutions\",\"description\":\"We Empower Your Business Growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\",\"name\":\"PheonixSolutions\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"width\":454,\"height\":300,\"caption\":\"PheonixSolutions\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/PheonixSolutions-209942982759387\\\/\",\"https:\\\/\\\/x.com\\\/pheonixsolution\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/5e146ea8682be704a2553a73c97c786b\",\"name\":\"bharat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g\",\"caption\":\"bharat\"},\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/author\\\/bharat\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pheonix Solutions - We Empower Your Business Growth","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/","og_locale":"en_US","og_type":"article","og_title":"Pheonix Solutions - We Empower Your Business Growth","og_description":"Step 1: Create the Project Directory and Files It should look something like this\u00a0 Step 2: Install Required Dependencies Install the essential dependencies, including React, TypeScript, and tslib, by running: npm install react typescript @types\/react tslib &#8211;save-dev Step 3: Configure TypeScript Generate a tsconfig.json file with default configurations: npx tsc&hellip; Continue Reading Building a Reusable React Component Library with TypeScript","og_url":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/","og_site_name":"PHEONIXSOLUTIONS","article_publisher":"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","article_published_time":"2024-11-27T04:08:17+00:00","article_modified_time":"2024-11-27T04:08:22+00:00","og_image":[{"url":"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S","type":"","width":"","height":""}],"author":"bharat","twitter_card":"summary_large_image","twitter_creator":"@pheonixsolution","twitter_site":"@pheonixsolution","twitter_misc":{"Written by":"bharat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/"},"author":{"name":"bharat","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/5e146ea8682be704a2553a73c97c786b"},"headline":"Building a Reusable React Component Library with TypeScript","datePublished":"2024-11-27T04:08:17+00:00","dateModified":"2024-11-27T04:08:22+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/"},"wordCount":670,"commentCount":0,"publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#primaryimage"},"thumbnailUrl":"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/","url":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/","name":"Pheonix Solutions - We Empower Your Business Growth","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#primaryimage"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#primaryimage"},"thumbnailUrl":"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S","datePublished":"2024-11-27T04:08:17+00:00","dateModified":"2024-11-27T04:08:22+00:00","breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#primaryimage","url":"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S","contentUrl":"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeVHj0PZpNbSyehL1IlA7VpjoikLH-XZ9fdpzVvrqQ2Iq6-96UxACm6p88oVG265EtXG10AqkJMks0kySgaHIw8t0g-Mh7bssd9848IdGuYnlAfAzJNM7uBnUAwq3Z-UO0N_HKgCQ?key=aeMqeUcqqg55WlVp1lCA9a6S"},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/blog\/building-a-reusable-react-component-library-with-typescript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Building a Reusable React Component Library with TypeScript"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/blog\/#website","url":"https:\/\/pheonixsolutions.com\/blog\/","name":"Pheonix Solutions","description":"We Empower Your Business Growth","publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pheonixsolutions.com\/blog\/#organization","name":"PheonixSolutions","url":"https:\/\/pheonixsolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","width":454,"height":300,"caption":"PheonixSolutions"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","https:\/\/x.com\/pheonixsolution"]},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/5e146ea8682be704a2553a73c97c786b","name":"bharat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d82d0f7350e396f4195f9cbac82c8173f0a2abae54e34fe15122bf92b23dca79?s=96&r=g","caption":"bharat"},"url":"https:\/\/pheonixsolutions.com\/blog\/author\/bharat\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7F4uM-2b5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/507"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8375"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8375\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}