VUE ROUTER: EASY STEPS TO ADDING ROUTING TO YOUR VUE APPLICATION
Tags: vue, router, routing
Published: 2023-06-15 22:24:12

Adding routing to your Vue application can be a bit of a hassle, particularly if you are new to Vue.js. I will be sharing a straightforward method to implement routing in this blog post using Vue CLI

## Setting Up:
The easiest way to get started with setting up routing in your Vue application is by creating a new project using Vue CLI and have CLI set up routing for you.

To get started, open your terminal or command prompt and follow these steps:

- Navigate to the directory where you want to create your new project. In this example, we will create the project in the Documents folder. You can change the directory path according to your preference.

```
cd Documents
```

![changing dircetory](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og9dz9rl5um25tqs5gu1.png)

- Once you have done this, use the following command to create a new Vue project named "my-router" (you can replace "my-router" with your preferred project name):

```
vue create my-router
```

- Vue CLI will prompt you to select a preset for your project. Scroll down to "manually select features" and press Enter. 

![select features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ticc9yefqu40i035exq6.png)

By choosing the "Manually select features" option, you'll have more control over your Vue project. This allows you to handpick the specific features and plugins you want to include in your project, including routing.

- After selecting the "Manually select features" option, a prompt will appear with a list of features to choose from. Scroll down using the arrow keys until you reach the "Router" option. Press the space bar to select it, indicated by a filled checkbox.

Next, scroll down to the "Linter" option and press the space bar to unselect it, indicated by an empty checkbox.

![select](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyiev9azdhdiv5ad6xx1.png)

Once you have made these selections, press Enter to proceed.

- The next prompt will ask you to choose a version. Select the latest version by scrolling down and highlighting it, then press Enter.

![select version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ik0ssp1komaa8kp5lhb.png)

- Following that, Vue CLI will ask if you want to use history mode for the router. Reply with "Y" to choose yes.

![history mode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egwdvhjmozywxu6kvd4z.png)

- Next, you will be prompted to select the configuration file format. Select the default config file by pressing Enter.

![config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itij2764gbjw10p9gexh.png)

- next select no "N' to saving it as a preset. 

![preset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr7a2eln3mpmw8jw359x.png)

Press enter and you will generate your vue application

![vue app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yewrk3mz2bqtw3pb2umm.png)

When you open your newly generated Vue application in VS Code, you will find that the router has been set up for you. You can now personalize it to meet your specific needs and requirements.

![vscode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yh1zh8m5vn65osvqqx1s.png)

If you found this blog post helpful, I would love to hear from you! Drop a comment below! Share your thoughts, feedback, or any additional tips and tricks you have discovered along the way. 

Happy coding!