Ejecting Create React App (CRA)

Rajitha Sanjayamal
2 min readMar 12, 2023

Have your ever created a new React project?

If answer is yes, you might have used create-react-app that helps quickly setup a new React project.
If answer is no, Don’t worry, Just run npx create-react-app [project_name] command. You will get a new project.

CRA provides a pre-configured setup that includes a development server, build tools and other useful features. Under the hood, it uses webpack and Babel. But you don’t need to know them in order to create a new React project.

However, there may be cases that you need to customize the setup provided by CRA.

Ejecting from CRA means that you remove the abstraction layer provided by CRA and get access to the underlying configuration files. This gives you move control over your project’s configuration.

To eject from default configuration, run npm run eject command in project directory. Ejecting is significant decision and you will be responsible for maintaining and updating the configuration yourself.

So keep in mind that,

This is a one way operation, once you eject you can’t go back.

Let’s see, what are the reasons that you might consider ejecting from default configuration.

  1. You want to use custom webpack configurations that’s not supported by CRA.
  2. You need more control over the build process.
  3. You want to use a different testing framework, CRA comes with Jest as default framework. If you prefer to use a different testing framework, ejecting can give you that flexibility.

In Conclusion, ejecting from default configuration can be a powerful tool if you need more control over your React project’s configuration. However, you should carefully consider the trade-offs before making the decision to eject.

--

--