Start to finish, open-wc "Hello World" guide for dummies (like myself)
Published: 2022-01-16 23:26:56

Hello everyone! Have you wanted to get into JavaScript and Open Web Components, but have no idea what either of those are, and need a step by step guide to get a "Hello World" page up and running? Well look no further because that is exactly where I was at about 3 days ago. 

##Before we get into it... What do all these words mean?
JavaScript is a programming language that allows users to interact with things on web pages. Open Web Components (commonly open-wc) is a tool that provides defaults and basic outlines for website framework. I think of it as sort of a shortcut to getting started on a website. In this guide we will be installing open-wc and using some Javascript to get our page up and running. 


##Downloads:
For this tutorial you're going to need VSCode and NodeJS. VSCode is Microsoft's code editing tool and it is really helpful because you can launch your pages right from the editor, and you can access your git repositories by linking your git account to the editor.

To get VSCode, go this go to [this website](code.visualstudio.com), select Download in the top right which will take you to this screen
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajjdvu04imz6n8srn3xo.png)

Select your OS and follow the onscreen instructions to get it set up

Now that we got that one out of the way let's get NodeJS. This is a runtime environment that runs and executes JavaScript code outside of your web browser. This will also by default install a npm which will allow you to interact with your .js files in a given directory. Head over [here](https://nodejs.org/en/download/), select LTS and your OS and then make sure that installs in the default file location. To check this, open a terminal or a command prompt and type 'node' and it should look like this 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qedhyvxwvlmdgwzvkh98.png) 


On to the web component now!

##Let's get going!

The first step here is to make a folder, call it what you like, but make sure you can access it. Using the cd command, navigate to the folder you just created, if you are unfamiliar how to navigate directories with cd check [here](https://help.ubuntu.com/community/UsingTheTerminal#File_.26_Directory_Commands)for further readings. 

After you have successfully entered the new folder, type `npm init @open-wc` and you should be met with this screen 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6o2i6isk0hz25jhotk7r.png)
 Using the arrow keys, hover over "Scaffold New Project" and hit enter. Next, hover over "Web Component" and press Enter again. Your screen should look like this: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpfez3mel5pei8l6oplb.png)
After that, you should select all 3 of the options "linting", "testing", and "demoing" do this by pressing the spacebar, then the down arrow to select each one, the radio buttons should be lit up as such:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bdgf9u38pfaqob1dj87.png)
Press enter when they are all selected.

When asked if you are going to use typescript, select no by pressing enter. 

Finally, you need to give your web component a name, for this example I used hello-world. After, select Yes to write to the file structure 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uijwde4aru2a3g0i0oiv.png) 
In this tutorial we are going to arrow key down and select "Yes with npm", that was installed with JSNode rather than Yarn, if you have yarn and would like to use it, go ahead and select Yes for that option at this stage [(read more about Yarn)](https://classic.yarnpkg.com/en/)

Congrats! Your first Web Component! If your screen looks like this, you did it!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4481pu548zhv9gvp7ke9.png)
All that's left to do is type `npm start` into terminal and bask in the glory of your new creation. Whenever that gets boring press `ctrl (or command) + C` 

##Further Readings and Links

[Here](https://github.com/hayden-angello/edtechjoker-lab1) is my git repository for this project, check yours against mine.
Also this is a link to Lit which helps you build web components super quick and easy by providing the base code for tons of things, check that out [here](https://lit.dev/playground/#sample=examples/hello-world)