소개
Nuxt로 모바일 앱을 처음부터 만들고 싶으신가요? 이 가이드는 처음부터 모바일용으로 구성된 새로운 Nuxt 4 프로젝트를 만들고, iOS 및 Android 네이티브 앱으로 패키징하는 과정을 안내합니다. Capacitor 8.
이 튜토리얼을 마치면 시뮬레이터에서 동작하는 모바일 앱을 갖게 되며, 계속 개발해 최종적으로 App Store와 Google Play에 출시할 수 있습니다.
소요 시간: 약 30분
만들게 될 것:
- 최신 디렉토리 구조를 갖춘 새로운 Nuxt 4 프로젝트
- 모바일용 정적 사이트 생성(SSG) 설정
- Capacitor 8과 필수 플러그인
- iOS 및 Android 네이티브 앱
- Live reload 개발 환경 구축
이미 Nuxt 앱을 사용 중인가요? 확인해 보세요 Nuxt 앱을 모바일로 전환하기 대신 사용하세요.
사전 요구사항
다음 도구들이 설치되어 있는지 확인하세요:
- Node.js 18+ (확인하려면
node --version) - Bun 패키지 매니저 (
curl -fsSL https://bun.sh/install | bash) - iOS 프로파일링 (macOS 전용, iOS 개발용)
- 디버깅하기 (Android 개발용)
1단계: 새로운 Nuxt 4 프로젝트 생성
먼저 새로운 Nuxt 4 프로젝트를 생성합니다:
bunx nuxi@latest init my-mobile-app
cd my-mobile-app
bun install
Nuxt 4 디렉토리 구조
Nuxt 4는 app code가 있는 새로운 디렉토리 구조를 사용하며, app/ 디렉토리:
my-mobile-app/
app/
assets/
components/
composables/
layouts/
middleware/
pages/
plugins/
utils/
app.vue
public/
server/
nuxt.config.ts
package.json
이 구조는 앱과 서버 code 간의 분리를 더 명확하게 해줍니다.
2단계: 정적 생성을 위한 Nuxt 설정
Capacitor에는 정적 HTML/JS/CSS 파일이 필요합니다. Nuxt를 정적 생성으로 설정하려면 다음에서: nuxt.config.ts:
export default defineNuxtConfig({
compatibilityDate: '2025-01-15',
devtools: { enabled: true },
// Enable static generation
ssr: true,
nitro: {
preset: 'static',
},
});
3단계: 모바일 스크립트 추가
다음 파일을 package.json 모바일 개발 스크립트로 업데이트하세요:
{
"scripts": {
"dev": "nuxt dev",
"build": "nuxt build",
"generate": "nuxt generate",
"preview": "nuxt preview",
"mobile": "bun run generate && bunx cap sync",
"mobile:ios": "bun run mobile && bunx cap open ios",
"mobile:android": "bun run mobile && bunx cap open android"
}
}
정적 생성을 테스트하세요:
bun run generate
다음이 보일 것입니다: .output/public 정적 파일이 있는 디렉토리입니다.
4단계: Capacitor 8 설치
Capacitor 코어 패키지를 설치하세요:
bun add @capacitor/core
bun add -D @capacitor/cli
대부분의 모바일 앱에 필요한 필수 플러그인을 설치하세요:
bun add @capacitor/app @capacitor/keyboard @capacitor/splash-screen @capacitor/status-bar @capacitor/preferences
플러그인 기능:
- @capacitor/app — 앱 라이프사이클 이벤트 (포그라운드/백그라운드, 딥 링크)
- @capacitor/keyboard — 키보드 동작 제어
- @capacitor/splash-screen — 네이티브 스플래시 화면 제어
- @capacitor/status-bar — 디바이스 상태 표시줄 스타일링
- @capacitor/preferences — 키-값 저장소 (localStorage와 비슷하지만 네이티브)
5단계: Capacitor 초기화
프로젝트 정보로 Capacitor를 초기화하세요:
bunx cap init "My Mobile App" com.example.mymobileapp --web-dir .output/public
변경 전:
"My Mobile App"앱 표시 이름 입력com.example.mymobileapp앱 ID 입력 (리버스 도메인 표기법)
다음이 생성됩니다: capacitor.config.ts. 플러그인 설정으로 업데이트하세요:
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.example.mymobileapp',
appName: 'My Mobile App',
webDir: '.output/public',
plugins: {
SplashScreen: {
launchShowDuration: 2000,
launchAutoHide: true,
androidScaleType: 'CENTER_CROP',
splashFullScreen: true,
splashImmersive: true,
},
Keyboard: {
resize: 'body',
resizeOnFullScreen: true,
},
StatusBar: {
style: 'dark',
},
},
};
export default config;
6단계: 네이티브 플랫폼 추가
플랫폼 패키지 설치:
bun add @capacitor/ios @capacitor/android
네이티브 프로젝트 생성:
bunx cap add ios
bunx cap add android
다음이 생성됩니다: ios 및 android 네이티브 프로젝트가 포함된 디렉토리입니다.
7단계: 빌드 및 실행
프로젝트를 빌드하고 네이티브 플랫폼과 동기화하세요:
bun run mobile
iOS Simulator에서 열기:
bun run mobile:ios
또는 Android Emulator:
bun run mobile:android
Xcode (iOS)에서:
- 기기 드롭다운에서 시뮬레이터를 선택하세요
- Play 버튼을 클릭하거나 누르세요
Cmd + R
Android Studio에서:
- Gradle 동기화가 완료될 때까지 기다려 주세요
- 기기 드롭다운에서 에뮬레이터를 선택하세요
- Run 버튼을 클릭하거나
Shift + F10
8단계: Live Reload 설정
더 빠른 개발을 위해 live reload를 활성화하세요. 변경 사항이 기기에 즉시 반영됩니다.
- 로컬 IP 주소를 확인하세요:
# macOS
ipconfig getifaddr en0
# Windows
ipconfig
- 개발용 Capacitor 설정을 생성합니다. 업데이트
capacitor.config.ts:
import type { CapacitorConfig } from '@capacitor/cli';
const devConfig: CapacitorConfig = {
appId: 'com.example.mymobileapp',
appName: 'My Mobile App',
webDir: '.output/public',
server: {
url: 'http://YOUR_IP_ADDRESS:3000',
cleartext: true,
},
plugins: {
// ... same plugin config
},
};
const prodConfig: CapacitorConfig = {
appId: 'com.example.mymobileapp',
appName: 'My Mobile App',
webDir: '.output/public',
plugins: {
// ... same plugin config
},
};
const config = process.env.NODE_ENV === 'development' ? devConfig : prodConfig;
export default config;
- dev server를 실행하고 설정을 native에 복사합니다:
bun run dev &
NODE_ENV=development bunx cap copy
- Xcode/Android Studio에서 다시 빌드
이제 Nuxt code를 수정하면 기기에서 바로 hot-reload됩니다.
9단계: 첫 모바일 화면 만들기
모바일 친화적인 홈 화면을 만들어 봅시다. 업데이트 app/app.vue:
<template>
<NuxtPage />
</template>
생성 app/pages/index.vue:
<template>
<main
class="min-h-screen bg-linear-to-b from-green-500 to-green-700 flex flex-col items-center justify-center p-6 text-white"
>
<h1 class="text-4xl font-bold mb-4">My Mobile App</h1>
<p class="text-xl mb-8 text-center opacity-90">
Built with Nuxt 4 + Capacitor 8
</p>
<div v-if="appInfo" class="bg-white/20 rounded-lg p-4 backdrop-blur-sm mb-8">
<p class="text-sm">
{{ appInfo.name }} v{{ appInfo.version }}
</p>
</div>
<div class="space-y-4 w-full max-w-sm">
<button
class="w-full py-4 px-6 bg-white text-green-600 rounded-xl font-semibold text-lg shadow-lg active:scale-95 transition-transform"
@click="handleGetStarted"
>
Get Started
</button>
<button
class="w-full py-4 px-6 bg-white/20 text-white rounded-xl font-semibold text-lg backdrop-blur-sm active:scale-95 transition-transform"
@click="handleShare"
>
Share App
</button>
</div>
</main>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { App } from '@capacitor/app';
const appInfo = ref<{ name: string; version: string } | null>(null);
let backButtonListener: { remove: () => void } | null = null;
onMounted(async () => {
// Get app info
try {
appInfo.value = await App.getInfo();
} catch (e) {
// Web fallback
appInfo.value = { name: 'My Mobile App', version: '1.0.0' };
}
// Handle Android back button
backButtonListener = await App.addListener('backButton', ({ canGoBack }) => {
if (!canGoBack) {
App.exitApp();
} else {
window.history.back();
}
});
});
onUnmounted(() => {
backButtonListener?.remove();
});
function handleGetStarted() {
// Navigate to onboarding or main app
console.log('Get started clicked');
}
async function handleShare() {
// We'll implement this with the Share plugin later
console.log('Share clicked');
}
</script>
10단계: Tailwind CSS 추가
스타일링을 적용하려면 프로젝트에 Tailwind CSS를 추가하세요:
bun add tailwindcss @tailwindcss/vite
업데이트 nuxt.config.ts:
import tailwindcss from '@tailwindcss/vite';
export default defineNuxtConfig({
compatibilityDate: '2025-01-15',
devtools: { enabled: true },
ssr: true,
nitro: {
preset: 'static',
},
css: ['~/assets/css/main.css'],
vite: {
plugins: [tailwindcss()],
},
});
생성 app/assets/css/main.css:
@import 'tailwindcss';
:root {
--sat: env(safe-area-inset-top);
--sar: env(safe-area-inset-right);
--sab: env(safe-area-inset-bottom);
--sal: env(safe-area-inset-left);
}
body {
padding-top: var(--sat);
padding-right: var(--sar);
padding-bottom: var(--sab);
padding-left: var(--sal);
}
/* Prevent text selection on mobile */
* {
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
/* Allow text selection in inputs */
input,
textarea {
-webkit-user-select: auto;
user-select: auto;
}
11단계: Share 플러그인 추가
이제 공유 버튼 기능을 구현해 보겠습니다:
bun add @capacitor/share
업데이트 app/pages/index.vue Share plugin을 사용하려면:
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { App } from '@capacitor/app';
import { Share } from '@capacitor/share';
// ... existing code ...
async function handleShare() {
try {
await Share.share({
title: 'Check out this app!',
text: 'Built with Nuxt 4 and Capacitor 8',
url: 'https://capacitorjs.com',
dialogTitle: 'Share with friends',
});
} catch (e) {
console.log('Share cancelled or failed:', e);
}
}
</script>
Sync 및 rebuild 실행:
bun run mobile
프로젝트 구조
프로젝트가 다음과 같이 보이면 성공입니다:
my-mobile-app/
├── android/ # Android native project
├── ios/ # iOS native project
├── .output/
│ └── public/ # Static build output
├── app/
│ ├── assets/
│ │ └── css/
│ │ └── main.css
│ ├── pages/
│ │ └── index.vue
│ └── app.vue
├── capacitor.config.ts # Capacitor configuration
├── nuxt.config.ts # Nuxt configuration
├── package.json
└── ...
다음 단계
이제 Nuxt 모바일 앱이 완성되었습니다. 다음 단계는 다음과 같습니다:
필수 설정
- 앱 아이콘: 기본 아이콘을 교체하세요
ios/App/App/Assets.xcassets및android/app/src/main/res - 스플래시 화면: 네이티브 프로젝트에서 설정하거나 사용하세요
@capacitor/splash-screen설정 - 딥 링크: 앱의 URL 스킴을 구성하세요
더 많은 기능 추가
- 카메라:
bun add @capacitor/camera - 위치 정보:
bun add @capacitor/geolocation - 푸시 알림:
bun add @capacitor/push-notifications또는 @capgo/capacitor-firebase-messaging iOS 및 Android용 Firebase Cloud Messaging 지원 - 파일 시스템:
bun add @capacitor/filesystem
네이티브 UI 및 트랜지션
네이티브 모바일 느낌을 위해 Konsta UI 대신 Capgo 플러그인을 사용하세요:
- @capgo/capacitor-native-navigation — Liquid Glass 탭 바 및 네이티브 네비게이션 바
- @capgo/capacitor-transitions — 네이티브 스타일의 페이지 전환 효과
bun add @capgo/capacitor-native-navigation @capgo/capacitor-transitions
bunx cap sync
Tailwind safe areas를 위해 다음을 추가하세요 @capgo/tailwind-capacitor:
bun add -D tailwind-capacitor
자세한 내용은 @capgo/capacitor-native-navigation 사용하기, @capgo/capacitor-transitions 사용하기, 그리고 tailwind-capacitor 레포지토리 Nuxt 전용 설정을 위해.
iOS 레이아웃 이슈 해결 (Viewport, Safe Area, 가로 오버플로우)
iOS에서 콘텐츠가 잘리거나, 밀리거나, 가로 스크롤이 생긴다면, 더 추가하거나 overflow-x: hidden viewport 태그를 조정하는 것만으로는 보통 해결되지 않습니다. 다음 점검을 순서대로 진행하세요.
viewport meta 태그가 올바르게 적용되었는지 확인하세요
다음에서 nuxt.config.ts, viewport는 다음을 통해 설정하세요 app.head:
export default defineNuxtConfig({
app: {
head: {
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1, viewport-fit=cover',
},
],
},
},
});
iOS safe area는 루트 래퍼 한 곳에서만 처리하세요
단일 앱 셸을 생성하고 그곳에 safe area 패딩을 적용하세요. 여러 중첩된 컴포넌트에 각각 적용하지 마세요:
html,
body,
#__nuxt {
width: 100%;
min-height: 100%;
margin: 0;
padding: 0;
overflow-x: hidden;
}
* {
box-sizing: border-box;
}
.app-shell {
min-height: 100dvh;
width: 100%;
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
모든 페이지 콘텐츠를 다음 안에 감싸세요: .app-shell. 헤더, 모달, 레이아웃 래퍼에 safe-area 패딩이 중복되면 UI가 잘리거나 너무 커 보일 수 있습니다.
사용하면 @capgo/tailwind-capacitor, 다음과 같은 유틸리티로 동일한 패딩을 표현할 수 있습니다. pt-safe pb-safe px-safe 해당 단일 셸에서.
Capacitor iOS를 설정하세요 contentInset 대상 never 먼저
다음에서 capacitor.config.ts, native inset을 비활성화하는 편이 좋고 CSS(또는 Native Navigation의 contentInsetMode: 'css')가 safe area를 제어하도록 하세요:
const config: CapacitorConfig = {
appId: 'com.example.myapp',
appName: 'my-app',
webDir: '.output/public',
ios: {
contentInset: 'never',
},
};
Capacitor의 자동 content inset과 CSS env(safe-area-inset-*) padding을 함께 쓰면 이중 여백이 생기는 흔한 원인입니다.
실제로 overflow되는 요소를 찾으세요
흔한 원인은 다음을 사용하는 요소입니다: 100vw, Tailwind w-screen, 고정 픽셀 너비 또는 큰 min-width.
Safari Web Inspector에서 다음을 실행하세요:
[...document.querySelectorAll('*')]
.filter(el => el.scrollWidth > document.documentElement.clientWidth)
.map(el => ({
el,
tag: el.tagName,
class: el.className,
scrollWidth: el.scrollWidth,
clientWidth: document.documentElement.clientWidth,
}));
Tailwind에서는 다음을 교체하세요: w-screen 포함 w-full 가능하면 사용하세요. 많은 가로 오버플로 문제는 100vw / w-screen중복된 safe-area 패딩이나 고정 너비 컨테이너 때문이며, viewport meta tag 자체 때문은 아닙니다.
Over-the-Air 업데이트
설정하기 Capgo App Store 재제출 없이 업데이트를 푸시하려면:
bunx @capgo/cli init
문제 해결
“Cannot find module” 오류로 빌드 실패
실행 bun install 다시 시도해 주세요.
iOS: “No signing identity found” 오류 Xcode를 열고 Signing & Capabilities로 이동한 뒤 개발 팀을 선택하세요.
Android: “SDK 위치를 찾을 수 없음”
생성 android/local.properties 포함 sdk.dir=/path/to/android/sdk
기기에 변경 사항이 반영되지 않음
변경 사항을 적용한 후 반드시 bun run mobile 를 실행했는지 확인하세요. 라이브 리로드를 사용하려면 IP 주소가 올바른지, 개발 서버가 실행 중인지 확인하세요.
.output/public 디렉토리가 비어 있거나 없습니다
설정 상태를 확인하세요 nitro: { preset: 'static' } 에서 nuxt.config.ts 그리고 다음을 실행하세요: bun run generate.
리소스
- Capacitor 8 문서
- Nuxt 4 문서
- Capgo - Live Updates
- @capgo/capacitor-native-navigation
- @capgo/capacitor-transitions
- @capgo/tailwind-capacitor
앱을 출시할 준비가 되셨나요? Capgo를 통해 업데이트를 더 빠르게 배포하는 방법을 알아보세요 — 무료 계정 가입하기 만들어 보세요.
Capacitor로 Nuxt 모바일 앱을 처음부터 만들기 8편 이어서 보기
사용 중이라면 Capacitor 8로 Nuxt 모바일 앱을 처음부터 만들기 CI/CD 자동화를 계획하려면, 다음을 연결하세요 Capgo CI/CD 설정하기 Capgo CI/CD의 제품 워크플로우용, Capgo Native Build Capgo Native Builds의 제품 워크플로우용, Capgo 연동 서비스 Capgo Integrations의 제품 워크플로우용, CI/CD 통합 CI/CD Integration의 구현 세부 사항은, 그리고 GitHub Actions 연동 GitHub Actions Integration의 구현 세부 사항을 참고하세요.