Module to use Font Awesome 6 icons in your Nuxt 3 project.
This module does not use vue-fontawesome under the hood as dependency,
but contains some code from its sources to implement its features with Nuxt Universal Render, also known as ssr: true in config.
The main difference from official component is creating real tags in template instead of rendering nodes in browser. That is why it works on server.
I tried to implement as many features I could (like mask, transform and symbol) but not sure if everything works the same way as in vue-fontawesome.
Please use issues to report problems.
npx nuxi@latest module add @vesp/nuxt-fontawesome
npm i -D @fortawesome/free-solid-svg-icons @fortawesome/free-regular-svg-icons @fortawesome/free-brands-svg-icons
@vesp/nuxt-fontawesome to modules in your nuxt.config.tsUse the fontawesome key:
  // nuxt.config.ts
  modules: [
    '@vesp/nuxt-fontawesome',
  ],
  fontawesome: {
    icons: {
      solid: ['cog', ...],
      ...
    }
  }
}
componentfont-awesomeDefault component name is <font-awesome icon="" ... />, and you can change that here.
For example, if you will specify fa, it will become <fa icon="" ... />.
Also see suffix.
useLayerstrueBoolean to indicate if the layers component should be registered globally.
Name of the component will be ${options.component}-layers, and <font-awesome-layers ... /> by default.
useLayersTexttrueBoolean to indicate if the layers component should be registered globally.
Name of the component will be the ${options.component}-layers-text, and <font-awesome-layers-text ... /> by default.
iconsWhich icons you will use. FontAwesome currently supports up to 5 icon styles in 3 families.
This option is an object with the style names as property and an array with all icon names you wish to use from those styles
  icons: {
    solid: ['coffee', 'child', ... ],
    regular: ['comment', ... ],
    brands: ['twitter', ... ],
  },
  proIcons: {
    solid: [],
    regular: [],
    light: [],
    thin: [],
    duotone: [],
  },
  sharpIcons: {
    solid: [], 
    regular: [],
    light: [],
    thin: [],
  }
addCsstrueIf the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the Nuxt css property.
suffixtrueBoolean whether to append -icon to the icon component name. This option exists as the component name option is also used for the layer components and you might not want to add '-icon' to those.
  // config
  component: 'fa',
  suffix: true
  // usage
  <fa-icon />
  <fa-layers />
  <fa-layers-text />
  // config
  component: 'fa',
  suffix: false
  // usage
  <fa />
  <fa-layers />
  <fa-layers-text />
You can find more details under playground folder.
npm i -D @fortawesome/free-solid-svg-iconsnuxt.config.jsDefault component names are:
<font-awesome><font-awesome-layers><font-awesome-layers-text>You can change this names by component option.
  // nuxt.config
  fontawesome: {
    icons: {
      solid: ['dollar-sign', 'cog', 'circle', 'check', 'calendar'],
      regular: ['user']
    }
  }
<template>
  <div>
    <font-awesome :icon="['far', 'user']" />
    <font-awesome icon="dollar-sign" style="font-size: 30px" />
    <font-awesome icon="cog" />
    <font-awesome-layers class="fa-4x">
      <font-awesome icon="circle" />
      <font-awesome icon="check" transform="shrink-6" :style="{color: 'white'}" />
    </font-awesome-layers>
    <font-awesome-layers full-width class="fa-4x">
      <font-awesome icon="calendar" />
      <font-awesome-layers-text transform="shrink-8 down-3" value="27" class="fa-inverse" />
    </font-awesome-layers>
  </div>
</template>
<script></script>
<template>
  <div>
    <font-awesome-layers full-width size="4x">
      <font-awesome :icon="faCircle" />
      <font-awesome-layers-text transform="shrink-12" value="GALSD" class="fa-inverse" />
    </font-awesome-layers>
    <font-awesome :icon="faAddressBook" />
    <font-awesome :icon="faGithub" />
  </div>
</template>
<script setup>
import {faCircle, faAddressBook} from '@fortawesome/free-solid-svg-icons'
import {faGithub} from '@fortawesome/free-brands-svg-icons'
</script>
You can use kits from Fontawesome Pro.
https://fontawesome.com/kits/**KIT_ID**/package (10 alpha-numerics characters)nuxt.config.ts by adding your kit ID under kitIdentifier key and icons required in project under proIcons.kit key:
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
    compatibilityDate: '2024-11-01',
    devtools: { enabled: true },
    modules: [
        '@vesp/nuxt-fontawesome'
    ],
    fontawesome: {
        kitIdentifier: (KIT_ID),
        proIcons: {
            kit: [
                (ICON_NAME ex: solid-user-circle-exclamation)
            ],
        },
    }
})
<font-awesome :icon="['fak', 'solid-user-circle-exclamation']" />
This module was inspired by official Nuxt 2 module from Nuxt Community.
Some code and function was taken from vue-fontawesome repository to implement its features with server rendering.