DEV Community

amberzoes
amberzoes

Posted on

How To Create Website App Without Create-React-App

I have created an app of this Apk sheep and traffic rider times using this code which really works that's why I am sharing this code with you. You can create an app for your website with this code I have created.

please note don't use it in production

First create a html file called index.html

https://bit.ly/3JxPUmN
https://bit.ly/3JxPUmN

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>React without create-react-app</title>
</head>
<body>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

add root div as react needs to render

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  + <div id="root"></div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

*Then add 3 scripts tag to work with react
*

<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
Enter fullscreen mode Exit fullscreen mode

*voila! write your react code within tag make sure the script tag have type of text/babel
*

<script type="text/babel">
function Welcome() {
  return <h1>Hello React World!</h1>;
}

ReactDOM.render(<Welcome/>, document.getElementById('root'));
</script>
Enter fullscreen mode Exit fullscreen mode

*Final code will be like this
*

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="root"></div>

<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
 function Welcome() {
  return <h1>Hello React World!</h1>;
 }

 ReactDOM.render(<Welcome/>, document.getElementById('root'));
</script>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)