How to get started with Material-UI? Here is the easy and the right way in my opinion. by and Material-UI Hai Nguyen Olivier Tassinari Just go and follow the instructions right here: _Razzle Material-UI example with Styled Components using Express with compression. Comes with HTML and inline CSS and JavaScript minification._github.com kireerik/razzle-material-ui-styled-example Wait! Are you on some kind of Unix based system? Mac? Linux? If so you might want to change the _PORT_ within the [_.env_](https://github.com/kireerik/razzle-material-ui-styled-example/blob/6ad048dbb9fb6565070c9bd48bb0617a052b2572/.env#L2) file, which I have set to _80_ which works on Windows. Razzle 's default is _3000_ so you can remove that line if you feel like it. The project is up and running. Start the server in development mode Go wild and experiment! I am not joking. Close this article right now and try the project instead! Just kidding! 😄 You can read on later… Are you lazy? Start the project on Codenvy instead! One click and the project is up and running after login. Are you still reading? All right, I will hold your hand and walk you through it. Usage Things will get boring here. I have told you to try it yourself instead. All right, jokes aside. We are getting serious here. Basic Folder structure public ⬅Static files are here. src – ⬅The main React.js component. – ⬅Serves the minified HTML. – client.js, index.js, static.js ⬅”Lower level” scripts (will discuss later). application/ Main.js server.js Source code As you may already figured out. The contains the React.js component. So basically you can change the main content of your site . Main.js here The , and serves all of this content as HTML when you visit the site. server.js renders the React.js application, collects the styles Inspect the source code! Yes, the dream came true. It is a properly minified one-liner. You can , mainly your header. modify your main HTML here How to actually start the project is detailed in the already linked readme. Features of the example project are listed there too. 📝 Code Styling components in is this easy with : Main.js Styled Components This is how Server Side Rendering works with Styled Components in : server.js It also includes some extra, like and HTML minification: compression for static resources Advanced The is the main entry point for the . This is required by Razzle. src/index.js server The is the main entry point for the . This is also required by Razzle. src/client.js browser The optional contains some environment variable definitions. .env You can find the build scripts in under the object. package.json scripts 📝 Code This is how the main entry point ( ) starts the server ( ): index.js server.js Here is the full . simplest version of index.js The entry point hydrates the already rendered application in the browser: client.js In , the script is using a build and run approach: package.json start Build and run Material-UI Server Side Rendering makes it a bit more complex to use Material-UI properly. Setting the is not necessarily straightforward (at least for me). However, the is not that bad. userAgent documentation The following codes with the links are hopefully giving some context: : server.js : client.js : Main.js Read this solution on Stack Overflow and press the vote up button if you find it useful too. Single route static site generation The optional is ( ). It grabs the already generated static resources and copies them into the folder. Plus it visits the URL and saves the HTML response: static.js called from the main server entry point index.js static Static site generation The static site generation script is somewhat complex: A regular Razzle build is created with the static setting ( ) baked into the generated server side code. RAZZLE_STATIC=true This build is started in mode. production The static generator is only executed this time. It performs the steps described before and closes the server. About the example Motivation I wanted to create a more current and appealing version of ’s . Why? Because I thought I could do it better and I still think I can.I quickly realized that I will need to combine a couple of technologies to implement my vision. Michael Morgenstern Search is Back! So “…after testing a bunch of example projects, I ended up finding and using Razzle.” ( source ) I also needed to choose between Material-UI and Muse UI. (Using material design was no question for me at this point.) I considered other libraries as well. But I quickly fell in love with Material-UI’s . It was really robust anyway. checkbox animation Material-UI’s checkbox animation First, I wanted to go with Muse UI, which is a port of Material-UI because I thought I would like Vue.js more than React.js. However, its documentation was Chinese only at the time, so I choose the original library instead. Having the CSS and HTML kind of combined into JavaScript using React.js felt a bit strange for the first time. Later, when I used Vue.js for some small client projects, I realized that I actually like the React way a bit more, especially with Styled Components. Eventually, I created this example project. So I was able to start with my real one called : Facebook Searcher _Search Facebook the regular way. Use various parameters to adjust and filter the results. Find your peers and reconnect with your old friends. Search by location, workplace, school, relation and many more._facebooksearcher.com Facebook Searcher Facebook Searcher It is a simple search form that builds a link so you can make custom searches currently for people on Facebook the regular way.You can already use the implemented fields and it already gives more freedom than its competitor. For example, you can list Facebook users with an interest in both sexes (which Facebook supports). It is still under development and some features are waiting for implementation.So feel free to let me know if you want to support this project in any way! Other reasons What is Razzle? A framework-agnostic build tool for server-rendered universal JavaScript applications. _✨ Create server-rendered universal JavaScript applications with no configuration. Works with React, Reason, Elm, Vue.js, and whatever comes next._github.com jaredpalmer/razzle Why Razzle? Server side rendering is easy with Razzle. This was a must have for me. Plus, it doesn’t force you to use solutions that you don’t want to use. So it “…is […] minimalistic…” ( source ) Hot module reloading is also a nice feature to have. Customizing or extending defaults is simple too. All this makes Razzle “…a nearly framework-agnostic build system…” which “…will 100% work with Angular, Vue, Rax, Preact, Inferno, React-XP, RN-Web…” — Jared Palmer ( source ) Who is using it? What’s next? was first “deployed” to an old-school hosting provider. I had Secure Shell access there, so I was able to install Node.js. Facebook Searcher I used Process Manager 2 to make sure it is running no matter what. Of course, this wasn’t as fast as having a static website. Plus, I didn’t have a good framework for deployments and updates in place. After a while, I started to save the HTML by hand and publish the application on Netlify this way. It was more reliable and the application loaded way faster too. Later on, I switched to Firebase Hosting, which is even faster and even more reliable in general. I implemented the static site generation feature somewhere at this point. Doing it by hand was unsustainable for sure. Now I can build and deploy Facebook Searcher with just one command. I can now focus hard on implementing the remaining features. Deploy with one command Deploying our application to Firebase Hosting is easy. Moreover, we can still deploy it as a Firebase Function instead ( ). Maybe this topic alone would worth another article regardless the easiness. basic example Currently, my project doesn’t come with rooting. If you need it for your project, you can add a router or you can consider using instead, which is basically Razzle with routing and related capabilities. After.js I am also looking forward to updating the project to the 1. version of Material-UI once they release it and add back the checkbox animations that I love so much. Take away Experimenting and or reading this article you can use Material-UI quickly and easily in a sophisticated way. So go ahead and build something wonderful! 🎉 Would you use this setup? Do you prefer something else? ⬇ , and in the comments below! Reply ask share your experience Did you enjoy this article? ⬅ 👏 the article a couple of times! Clap this step-by-step guide your and colleges! Share with friends ⬅ Use the Twitter and Facebook buttons to do so. Copy the link from the address bar. Message your peers directly. 👋Say hi and send the article to them. 💌 Newsletter by Erik Engi and get actionable technical articles into your inbox. Subscribe now Erik will only email you when he has something important to say. Just like you, he is usually very busy. So this will only happen every now and then and you can unsubscribe at any time. Follow to get notified about new articles. Erik Engi on Medium _Read writing from Erik Engi on Medium. Web developer, Ex-Codementor, Creator of Best Arcade Script and Member of the CodersClan._medium.com Erik Engi — Medium Work with Erik Engi Do you or your company have valuable projects and products? Want to extend your team with a world-class developer? – Erik is available for hire Hire now _HTML5 web application development. Erik Engi works with companies and developers world wide. Hire a world-class developer for your team!_oengi.com Oengi.com Erik can work full time for you or at your company. Do you or your team need programming help? s with Erik! Book 1:1 session Originally published at codementor.io .