Skip to content

Getting Started

This guide will walk you through setting up your development environment and creating your first Vue 3 project using the Altersquare boilerplate.

Prerequisites

Before you begin, you'll need to install some tools and obtain the necessary access.

1. Node.js

Node.js is required to run the development server and build your project.

Check if Node.js is installed:

bash
node --version
# Expected output: v22.x.x or higher

Installation Options:

nvm (Node Version Manager) allows you to install and switch between multiple Node.js versions easily.

Step 1: Install nvm

Windows:

bash
# Download and run the nvm-windows installer from:
# https://github.com/coreybutler/nvm-windows/releases
# Download nvm-setup.exe and run it

# After installation, open a new terminal and verify:
nvm --version

macOS/Linux:

bash
# Install nvm using curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Or using wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Restart your terminal or run:
source ~/.bashrc   # for bash
source ~/.zshrc    # for zsh

# Verify installation
nvm --version

Step 2: Install Node.js using nvm

bash
# Install Node.js 22 (recommended)
nvm install 22

# Use Node.js 22
nvm use 22

# Set as default version
nvm alias default 22

# Verify installation
node --version
# Expected output: v22.x.x

Why Node 22?

Vue 3 and Vite work best with Node.js 22 (latest LTS). Older versions may cause compatibility issues with some dependencies.

Why use nvm?

nvm is recommended because it allows you to:

  • Install multiple Node.js versions side by side
  • Switch between versions for different projects
  • Avoid permission issues with global npm packages

2. npm (Node Package Manager)

npm comes bundled with Node.js. Verify it's installed:

bash
npm --version
# Expected output: 9.x.x or higher

Alternative Package Managers

You can also use yarn or pnpm if you prefer. Replace npm install with yarn or pnpm install in the commands below.

3. Git

Git is required to clone the boilerplate repository.

Check if Git is installed:

bash
git --version
# Expected output: git version 2.x.x

Installation:

  • Windows: Download from git-scm.com
  • macOS: brew install git or Xcode Command Line Tools
  • Linux: sudo apt install git (Ubuntu/Debian)

Configure Git Identity:

After installing Git, configure your identity (required for commits):

bash
# Set your name
git config --global user.name "Your Name"

# Set your email
git config --global user.email "your.email@company.com"

# Verify configuration
git config --global user.name
git config --global user.email

4. Code Editor

We recommend Visual Studio Code with the following extensions:

ExtensionPurpose
VolarVue 3 language support
ESLintCode linting
PrettierCode formatting
SCSS IntelliSenseSCSS autocomplete

Disable Vetur

If you have Vetur installed (for Vue 2), disable it for Vue 3 projects. Volar is the official Vue 3 extension.

5. GitHub Access

You'll need access to the Altersquare GitHub organization:

Requesting Access:

Contact your Team Lead or Project Manager to request access. Provide the following information:

  • Your GitHub username
  • Which repositories you need access to (at minimum: vue3-boilerplate)

Step 1: Verify Access

Once access is granted, verify you can access the repository:

Method 1: Check via GitHub Web Interface

  1. Go to github.com/altersquare/vue3-boilerplate
  2. If you can see the repository (not a 404 error), you have access
  3. Try clicking the Code button - you should see clone options

Method 2: Test Clone via Command Line

bash
# Try cloning the repository
git clone https://github.com/altersquare/vue3-boilerplate.git test-clone

# If successful, you'll see:
# Cloning into 'test-clone'...
# remote: Enumerating objects: 45, done.
# ...

# Clean up the test clone
cd ..
rm -rf test-clone  # or rmdir /s test-clone on Windows

Step 2: Configure Git Authentication

Using HTTPS (Recommended):

HTTPS is the simplest way to authenticate with GitHub. When you clone or push, Git will prompt you for your credentials.

First-time Setup:

bash
# Test authentication
git clone https://github.com/altersquare/vue3-boilerplate.git

What Happens on First Clone:

  1. Git will prompt for your GitHub username
  2. Git will prompt for your password (or Personal Access Token)
  3. On Windows: Git Credential Manager will open a browser window for authentication
  4. On macOS: Keychain will store your credentials
  5. On Linux: Credentials will be stored in ~/.git-credentials

Where to Find Everything

Before you start, here's where to find all the resources you'll need:

📦 Repositories

ResourceLocationDescription
Vue 3 BoilerplateGitHub RepositoryThe starter template for new projects
Component LibraryComponents DocumentationCopy-paste Vue components and composables

📚 Documentation

ResourceLocationDescription
Getting Started GuideGetting StartedThis guide - step-by-step setup instructions
Project StructureProject StructureDetailed explanation of all folders and files
Component Library UsageUsing Component LibraryHow to integrate components into your project
ComposablesComposables DocumentationAvailable composables in the component library

🛠️ Tools & Utilities

ResourceLocationDescription
Color Name FinderColor Name Finder ToolUtility to find color names from hex codes

📖 Guides & Workflows

ResourceLocationDescription
Deployment FlowDeployment GuideHow to deploy and upload assets to CDN

🔑 Access Requirements

Access TypeWhere to Get ItWho to Contact
GitHub Organization AccessRequest from team leadYour project manager or team lead
API Base URLFrom backend teamBackend/API team lead
Environment Variables.env file in boilerplateCheck with project setup or team lead
Component Library AccessGitHub repositorySame as boilerplate access

Project Setup

Now that you have all prerequisites, let's set up your project.

Step 1: Clone the Boilerplate

bash
# Clone the repository
git clone https://github.com/altersquare/vue3-boilerplate.git my-project

Expected output:

Cloning into 'my-project'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (32/32), done.
Receiving objects: 100% (45/45), 15.20 KiB | 2.17 MiB/s, done.
Resolving deltas: 100% (12/12), done.

Step 2: Navigate to the Project

bash
cd my-project

Step 3: Install Dependencies

bash
npm install

Expected output:

added 150 packages, and audited 151 packages in 12s

25 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

What this does:

  • Reads package.json to see all required dependencies
  • Downloads and installs all packages into node_modules/ folder
  • Creates package-lock.json to lock dependency versions
  • This may take 1-5 minutes depending on your internet speed

Verify installation:

bash
# Check if node_modules folder was created
ls node_modules  # macOS/Linux
dir node_modules  # Windows

# You should see many folders (vue, vite, pinia, etc.)

Step 4: Environment Configuration

Step 4.1: Locate the .env file

The .env file should be in the root of your project (same level as package.json):

bash
# Check if .env file exists
ls -la .env  # macOS/Linux
dir .env     # Windows

# If it doesn't exist, create it:
touch .env   # macOS/Linux
type nul > .env  # Windows

Step 4.2: Configure Environment Variables

Open the .env file in your code editor and add your configuration:

env
# API Configuration
VITE_API_BASE_URL=https://api.yourdomain.com

What to Configure:

VariableDescriptionExample
VITE_API_BASE_URLBase URL for your API endpointshttps://api.yourdomain.com or http://localhost:3000

For Local Development:

env
# Local development API
VITE_API_BASE_URL=http://localhost:3000

For Staging/Production:

env
# Staging API
VITE_API_BASE_URL=https://api-staging.yourdomain.com

# Production API
VITE_API_BASE_URL=https://api.yourdomain.com

Environment Variables

  • All environment variables must be prefixed with VITE_ to be accessible in your Vue code
  • Update the .env file with your project-specific values
  • Never commit sensitive data (API keys, secrets) to .env - use .env.local for secrets (git-ignored)

Step 4.3: Verify Environment Variables

Accessing environment variables in your code:

js
// In any Vue file or JavaScript module
const apiUrl = import.meta.env.VITE_API_BASE_URL;
console.log("API URL:", apiUrl);

// In network/appAxios.js (if configured)
const baseURL = import.meta.env.VITE_API_BASE_URL;

Test that variables are loaded:

bash
# Restart dev server after changing .env
npm run dev

Then check the browser console - you should see your API URL logged.

Step 4.4: Environment-Specific Files (Optional)

You can create environment-specific files:

  • .env - Default values (committed to git)
  • .env.local - Local overrides (git-ignored, for secrets)
  • .env.development - Development environment
  • .env.production - Production environment

Vite automatically loads the appropriate file based on the mode.

Step 5: Run the Development Server

bash
npm run dev

Expected output:

  VITE v5.x.x  ready in 500 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.1.100:5173/
  ➜  press h + enter to show help

🎉 Congratulations! Open http://localhost:5173 in your browser to see your app.

Step 5.1: Verify the Application is Running

  1. Open your browser and navigate to http://localhost:5173
  2. You should see:
    • The Vue 3 application homepage
    • No console errors (check browser DevTools)
    • Hot Module Replacement (HMR) working - try editing a file and see it update automatically

Step 5.2: Test Hot Module Replacement (HMR)

  1. Open src/views/HomeWrapper.vue (or any Vue file)
  2. Make a small change (e.g., change some text)
  3. Save the file
  4. The browser should automatically update without a full page refresh

Step 5.3: Check Browser Console

Open browser DevTools (F12) and check:

  • Console tab - Should have no errors
  • Network tab - Should show successful requests
  • Vue DevTools (if installed) - Should show Vue component tree

Step 5.4: Verify Project Structure

bash
# Check that all key folders exist
ls src/assets      # Should show scss/, images/, getAssets.js
ls src/components  # Should show component folders
ls src/composable  # Should show composable files
ls src/stores      # Should show store files
ls src/views       # Should show view files

If something doesn't work:

  1. Check terminal for errors - Look for red error messages
  2. Check browser console - Press F12 and look at Console tab
  3. Verify Node.js version - Run node --version (should be 22.x)
  4. Clear cache and reinstall:
    bash
    rm -rf node_modules package-lock.json  # macOS/Linux
    rmdir /s node_modules & del package-lock.json  # Windows
    npm install

Step 6: Build for Production

When you're ready to deploy:

bash
# Create a production build
npm run build

Expected output:

vite v5.x.x building for production...
✓ 45 modules transformed.
dist/index.html                  0.45 kB │ gzip:  0.29 kB
dist/assets/index-DiwrgTda.css   5.20 kB │ gzip:  1.45 kB
dist/assets/index-CdGHgJpr.js   85.32 kB │ gzip: 27.15 kB
✓ built in 2.50s

Preview the production build locally:

bash
npm run preview

Integrating the Component Library

The Altersquare component library provides ready-to-use Vue 3 components that you can copy directly into your boilerplate project. This section explains how to find, copy, and use components from the library.

Step 1: Access the Component Library

Where to Find Components:

  1. Component Library Documentation:

  2. Deployed Component Library:

  3. Component Library Repository:

Step 2: Browse Available Components

Component Categories:

CategoryComponentsUse Case
Form ComponentsInput, TextArea, Checkbox, Radio, DatePicker, Dropdown, FileInput, Switch, Slider, RangeBuilding forms and collecting user input
UI ComponentsAccordion, Tabs, BreadCrumb, Snackbar, Pagination, ChipDisplaying content and navigation
Progress ComponentsLoader, LinearProgress, CircularProgressShowing loading states
Navigation ComponentsHorizontalAppBar, VerticalAppBarApp navigation and headers
Base ComponentsMenu, Table, ScrollObserver, Toast, PopOver, TooltipCore UI elements

View All Components:

Step 3: Copy a Component to Your Project

Example: Adding an Input Component

Step 3.1: Find the Component Code

  1. Navigate to Input Component Documentation
  2. Click on the Code tab or view the source code
  3. Copy the entire component code

Step 3.2: Create Component File in Your Project

bash
# Navigate to your project's components folder
cd src/components

# Create a folder for shared components (if it doesn't exist)
mkdir -p sharedComponents  # macOS/Linux
mkdir sharedComponents     # Windows

# Create the component file
touch sharedComponents/OInput.vue  # macOS/Linux
type nul > sharedComponents\OInput.vue  # Windows

Step 3.3: Paste Component Code

  1. Open src/components/sharedComponents/OInput.vue in your editor
  2. Paste the component code you copied from the library
  3. Save the file

Step 3.4: Verify Component Structure

Your component file should look like:

vue
<template>
  <!-- Component template -->
</template>

<script setup>
// Component logic
</script>

<style lang="scss" scoped>
// Component styles
</style>

Step 4: Use the Component in Your Project

Step 4.1: Import the Component

In any Vue file where you want to use the component:

vue
<script setup>
import OInput from "@/components/sharedComponents/OInput.vue";
</script>

Step 4.2: Use in Template

vue
<template>
  <div>
    <OInput
      v-model="email"
      label="Email Address"
      type="email"
      placeholder="Enter your email"
    />
  </div>
</template>

<script setup>
import { ref } from "vue";
import OInput from "@/components/sharedComponents/OInput.vue";

const email = ref("");
</script>

Step 5: Copy Composables from the Library

Step 5.1: Find Composable Code

  1. Navigate to Composables Documentation
  2. Or browse the composables in the component library repository
  3. Copy the composable code

Step 5.2: Add to Your Project

bash
# Navigate to composable folder
cd src/composable

# Create the composable file
touch useToastComposable.js  # macOS/Linux
type nul > useToastComposable.js  # Windows

Step 5.3: Paste and Use

  1. Paste the composable code into the file
  2. Import and use in your components:
vue
<script setup>
import { useToast } from "@/composable/useToastComposable";

const toast = useToast();

const showSuccess = () => {
  toast.success("Operation completed!");
};
</script>

Step 6: Organize Your Components

Recommended Folder Structure:

src/components/
├── sharedComponents/          # Components from library
│   ├── OInput.vue
│   ├── OButton.vue
│   ├── OToast.vue
│   ├── OSnackbar.vue
│   └── OPopup.vue
└── [FeatureName]/             # Feature-specific components
    └── [ComponentName].vue

Naming Convention:

  • Library components: Keep original names (e.g., OInput.vue, OToast.vue)
  • Your custom components: Use descriptive names (e.g., UserProfileCard.vue, ProductList.vue)

Step 7: Verify Component Works

Test Your Component:

  1. Start dev server (if not running):

    bash
    npm run dev
  2. Create a test page or modify an existing view:

    vue
    <!-- src/views/TestComponentsWrapper.vue -->
    <template>
      <div class="test-page">
        <h1>Testing Components</h1>
        <OInput v-model="testValue" label="Test Input" />
        <button @click="showToast">Test Toast</button>
      </div>
    </template>
    
    <script setup>
    import { ref } from "vue";
    import OInput from "@/components/sharedComponents/OInput.vue";
    import { useToast } from "@/composable/useToastComposable";
    
    const testValue = ref("");
    const toast = useToast();
    
    const showToast = () => {
      toast.success("Component is working!");
    };
    </script>
  3. Add route (if needed):

    js
    // src/router/index.js
    {
      path: '/test-components',
      name: 'TestComponents',
      component: () => import('@/views/TestComponentsWrapper.vue')
    }
  4. Visit the page in your browser and test the component

Step 8: Customize Components (Optional)

Since you have the source code, you can customize components:

Option 1: Modify Directly

  1. Open the component file (e.g., OInput.vue)
  2. Modify styles, props, or logic as needed
  3. Save and see changes immediately (HMR)

Option 2: Extend Component

Create a wrapper component:

vue
<!-- src/components/sharedComponents/CustomInput.vue -->
<template>
  <OInput v-bind="$attrs" :class="['custom-input', $attrs.class]" />
</template>

<script setup>
import OInput from "./OInput.vue";
</script>

<style lang="scss" scoped>
.custom-input {
  // Your custom styles
}
</style>

Best Practices

  1. Copy only what you need - Don't copy all components at once, add them as needed
  2. Keep library components separate - Use sharedComponents/ folder for library components
  3. Document customizations - If you modify a library component, document the changes
  4. Update components - Periodically check library for updates and improvements
  5. Use composables correctly - Always mount required components for composables to work

📖 Related Documentation:


Common Commands Reference

CommandDescription
npm run devStart development server with hot reload
npm run buildCreate production build in dist/
npm run previewPreview production build locally
npm run lintRun ESLint to check code quality
npm run lint:fixAuto-fix linting issues

Need more help? Check the Guides section or reach out to your team lead.