### Monorepo Directory Structure Example Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/6.web-and-device.md Illustrates a potential directory structure for a monorepo setup, separating Nuxt applications for web and devices, and a shared core package. ```bash - apps - nuxt-web - ... - nuxt.config.ts - nuxt-device - ... - nuxt.config.ts - packages - core - components - composables - ... ``` -------------------------------- ### Start Nuxt Development Server Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md Run the Nuxt development server with the `-o` flag to open the application in your default browser. ```bash yarn dev -o ``` ```bash npm run dev -- -o ``` ```bash pnpm dev -o ``` -------------------------------- ### Install Capacitor Live Update Plugin Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Install the necessary plugin for live updates using npm. After installation, sync your Capacitor project. ```bash npm install --save @capawesome/capacitor-live-update npx cap sync ``` -------------------------------- ### Install Capawesome CLI Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Install the Capawesome Command Line Interface globally to manage your live update bundles. ```bash npm i -g @capawesome/cli ``` -------------------------------- ### Check and Apply Live Updates Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Use the LiveUpdate.sync() method to check for and download updates. Call LiveUpdate.reload() to apply the update immediately, or it will be applied on the next app start. ```typescript import { LiveUpdate } from "@capawesome/capacitor-live-update" const sync = async () => { const result = await LiveUpdate.sync() if (result.nextBundleId) { await LiveUpdate.reload() } } ``` -------------------------------- ### Directory Structure for Reusable Tabs Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/3.app-tabs.md Illustrates the file structure for organizing reusable views across tabs using Nuxt's file-based routing. This setup allows multiple tabs to render the same component. ```text pages/ --| tabs.vue --| tabs/ ----| home/ ------| index.vue ------| album-[id].vue ----| search/ ------| index.vue ------| album.vue ----| library/ ------| index.vue ``` -------------------------------- ### Basic Page Structure Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md This is an example of a basic page component in Nuxt Ionic. The root component must be `` for proper Ionic navigation and transitions. ```vue ``` -------------------------------- ### Add Nuxt Ionic Module to Dev Dependencies Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/2.installation.md Install the Nuxt Ionic module as a development dependency using the Nuxt CLI. ```bash npx nuxi@latest module add ionic ``` -------------------------------- ### Sync Nuxt Build with Capacitor Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md Sync the Nuxt web build with your native iOS or Android project using Capacitor. This command copies the web build and configuration files, updates plugins, and installs necessary dependencies. ```bash npx @ionic/cli capacitor sync ios --no-build ``` ```bash npx @ionic/cli capacitor sync android --no-build ``` -------------------------------- ### Tab Content Page Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/3.app-tabs.md A basic Vue component representing the content for a specific tab. Ensure all tab pages start with an ion-page component. ```vue ``` ```vue ``` -------------------------------- ### Override Primary Color CSS Variables Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/2.theming.md Create a `~/assets/css/ionic.css` file to override Ionic's default CSS variables. This example shows how to override the primary color variables. ```css :root { --ion-color-primary: #57e389; --ion-color-primary-rgb: 87, 227, 137; --ion-color-primary-contrast: #000000; --ion-color-primary-contrast-rgb: 0, 0, 0; --ion-color-primary-shade: #4dc879; --ion-color-primary-tint: #68e695; /* And so on... */ } ``` -------------------------------- ### Enable Capacitor and Add Platforms (npm) Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Use npm commands to enable Capacitor integration and add iOS and Android platforms. Ensure your npm client is configured if necessary. ```bash # ionic config set -g npmClient npm ionic integrations enable capacitor ionic capacitor add ios ionic capacitor add android ``` -------------------------------- ### Enable Capacitor and Add Platforms (npx) Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Use npx to enable Capacitor integration and add iOS and Android platforms to your project. ```bash npx @ionic/cli integrations enable capacitor npx @ionic/cli capacitor add ios npx @ionic/cli capacitor add android ``` -------------------------------- ### Create Live Update Bundle Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Use the Capawesome CLI to create a new bundle for your live update. Specify the path to your built web app artifacts (e.g., the 'dist' folder). ```bash npx capawesome apps:bundles:create --path dist ``` -------------------------------- ### Enable Capacitor and Add Platforms (yarn) Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Use yarn commands to enable Capacitor integration and add iOS and Android platforms. Configure the Ionic CLI to use yarn. ```bash ionic config set -g npmClient yarn ionic integrations enable capacitor ionic capacitor add ios ionic capacitor add android ``` -------------------------------- ### Build and Sync Capacitor Project Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Generate a web build of your Nuxt application and sync it with your Capacitor project directories before running. ```bash npx nuxt generate npx cap sync ``` -------------------------------- ### Enable Capacitor and Add Platforms (pnpm) Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Use pnpm commands to enable Capacitor integration and add iOS and Android platforms. Configure the Ionic CLI to use pnpm. ```bash ionic config set -g npmClient pnpm ionic integrations enable capacitor ionic capacitor add ios ionic capacitor add android ``` -------------------------------- ### Programmatic Navigation with IonRouter Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md Demonstrates programmatic navigation using `useIonRouter`. This composable should be used instead of `useRouter` for full Ion Router benefits. It allows for pushing, going back, replacing routes, and custom animated navigation. ```vue ``` -------------------------------- ### Build Nuxt App for Production Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Generate the production build of your Nuxt application. The output is typically placed in the 'dist' folder, which serves as the bundle artifact for live updates. ```bash npx nuxt generate ``` -------------------------------- ### Android Development Script Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md A bash script to automate the local development process for Android, including building, syncing with Capacitor, and running the app with live reload. ```bash #!/bin/bash LIP=$(ipconfig getifaddr en0) echo "🍦 Starting local development to android device - ensure local dev server is running already" echo "🏗️ Type checking and building for development..." pnpm run build:dev echo "🔃 Capacitor installation, podfile installation, sync and copy to app distribution folders..." npx @ionic/cli capacitor sync android --no-build echo "🏃 Select an Android device to run the build at local ip address ${LIP} on..." eval "npx @ionic/cli capacitor run android --livereload-url=http://${LIP}:3000 --external --mode development" ``` -------------------------------- ### Package.json Scripts for Native Development Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md Define npm/yarn/pnpm scripts in `package.json` to easily execute the custom Android and iOS development bash scripts. ```json { "scripts": { "android": "bash ./scripts/android.sh", "ios": "bash ./scripts/ios.sh" } } ``` -------------------------------- ### iOS Development Script Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md A bash script to automate the local development process for iOS, including building, syncing with Capacitor, and running the app with live reload. ```bash #!/bin/bash LIP=$(ipconfig getifaddr en0) echo "🍦 Starting local development to ios device - ensure local dev server is running already" echo "🏗️ Type checking and building for development..." pnpm run build:dev echo "🔃 Capacitor installation, podfile installation, sync and copy to app distribution folders..." npx @ionic/cli capacitor sync ios --no-build echo "🏃 Select an iOS device to run the build at local ip address ${LIP} on..." eval "npx @ionic/cli capacitor run ios --livereload-url=http://${LIP}:3000 --external --mode development" ``` -------------------------------- ### Execute Native Development Scripts Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md Run the custom scripts for iOS and Android development using your preferred package manager (yarn, npm, or pnpm). ```bash yarn ios yarn android ``` ```bash npm run ios npm run android ``` ```bash pnpm run ios pnpm run android ``` -------------------------------- ### Open Capacitor Project in Native IDE Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Open your Capacitor project in Android Studio or Xcode for further development or debugging. ```bash npx cap open android npx cap open ios ``` -------------------------------- ### Run Capacitor App on Device/Emulator Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/4.enabling-capacitor.md Run your Capacitor application on an Android or iOS emulator or connected device using the command line. ```bash npx cap run android npx cap run ios ``` -------------------------------- ### Configure App ID for Live Updates Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/7.live-updates.md Set the 'appId' in your 'capacitor.config.json' to link your app with Capawesome Cloud. Replace the placeholder with your actual App ID. ```json { "plugins": { "LiveUpdate": { "appId": "00000000-0000-0000-0000-000000000000" } } } ``` -------------------------------- ### Run Nuxt App on Native Device with LiveReload Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/2.local-development.md Deploy the Nuxt application to a native iOS or Android device/simulator with live reloading enabled. Ensure your local IP address is correctly configured for the livereload URL. ```bash npx @ionic/cli capacitor run ios --livereload-url=http://${LIP}:3000 --external --mode development ``` ```bash npx @ionic/cli capacitor run android --livereload-url=http://${LIP}:3000 --external --mode development ``` -------------------------------- ### Implementing Route Middleware in Nuxt Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md Integrate Nuxt's route middleware for controlling access to routes. Define middleware in `middleware/` and apply it using `definePageMeta`. ```typescript export default defineNuxtRouteMiddleware((to, from) => { // isAuthenticated() is an example method verifying if a user is authenticated if (isAuthenticated() === false) { return showLoginModal(); // showLoginModal() is an example of opening a modal flow for authentication } }) ``` ```vue ``` -------------------------------- ### Manual Ionic Animation Usage Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/4.module-utilities.md Manually create and play Ionic animations using `createAnimation`. This method is recommended for grouped or chained animations, which are not supported by the `IonAnimation` component. ```vue ``` -------------------------------- ### Auto-imported Icons Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/5.icons.md Use icons directly in your template by referencing them with the ionicons prefix. The names are derived from the ionicons website by converting kebab-case to camelCase. ```vue ``` -------------------------------- ### Default app.vue Structure Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/1.customising-app-vue.md This is the basic structure for a custom app.vue file when using Nuxt Ionic. It includes the necessary `` and `` components for Ionic to function correctly. ```vue ``` -------------------------------- ### Manual Icon Imports Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/5.icons.md Manually import specific icons from 'ionicons/icons' when you need more control or want to avoid auto-importing. This is useful for managing dependencies or when auto-importing is disabled. ```vue ``` -------------------------------- ### Home Tab Album View Component Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/3.app-tabs.md Defines the Vue component for displaying a single album within the home tab. This component can be reused across different tabs. ```vue ``` -------------------------------- ### Configure Nuxt to Use Custom CSS Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/2.theming.md Add your custom CSS file to the `css` property in your `nuxt.config.ts` file to ensure it is included in your application. ```typescript export default defineNuxtConfig({ css: ['~/assets/css/ionic.css'], }) ``` -------------------------------- ### Configure Nuxt Module Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/2.installation.md Add the '@nuxtjs/ionic' module to your Nuxt configuration file. It is recommended to set 'ssr: false' if deploying to iOS or Android. ```javascript export default defineNuxtConfig({ modules: ['@nuxtjs/ionic'], ssr: false, }) ``` -------------------------------- ### Define Root Alias for Pages Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md Use `definePageMeta` to set an alias for a page, typically used to define the root path of the application when `~/pages/index.vue` is not present. ```ts definePageMeta({ alias: ['/'], }) ``` -------------------------------- ### Nuxt Module Configuration Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/3.configuration.md Configure the Nuxt Ionic module by specifying options for integrations, CSS, and global config within your nuxt.config.ts file. This is the primary way to customize module behavior. ```javascript export default defineNuxtConfig({ modules: ['@nuxtjs/ionic'], ionic: { integrations: { // }, css: { // }, config: { // } }, }) ``` -------------------------------- ### Accessing Route Parameters in Nuxt Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md Access route parameters within your Nuxt pages using the `useRoute()` composable. This is consistent with standard Nuxt practices. ```vue ``` -------------------------------- ### App Tabs Layout Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/3.cookbook/3.app-tabs.md This Vue component sets up the main tab bar and router outlet for an Ionic application. It includes navigation buttons for different tabs. ```vue ``` -------------------------------- ### Global Ionic Component Configuration Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/1.get-started/3.configuration.md Set global configurations for Ionic components, such as ripple effect and mode, within the 'config' section of your nuxt.config.ts. Refer to Ionic documentation for available options. ```javascript export default defineNuxtConfig({ ionic: { config: { rippleEffect: false, mode: 'md', // ... }, }, }) ``` -------------------------------- ### IonAnimation Component Usage Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/4.module-utilities.md Use the `IonAnimation` component for a declarative way to implement Ionic animations. It directly maps to Ionic's animation props. ```vue ``` -------------------------------- ### Disable Icon Auto-Import Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/5.icons.md Opt-out of auto-importing icons by setting the 'icons' integration option to 'false' in your nuxt.config.ts file. This requires manual imports for all icons. ```javascript export default defineNuxtConfig({ ionic: { integrations: { icons: false, }, }, }) ``` -------------------------------- ### Ionic Component Navigation with router-link Source: https://github.com/nuxt-modules/ionic/blob/main/docs/content/2.overview/1.routing.md Use the `router-link` attribute on Ionic components for simple navigation. It supports named routes, direct paths, and options for direction and animation. ```vue ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.