https://github.com/skyatura/faker-nuxt
Faker wrapper for Nuxt.js
https://github.com/skyatura/faker-nuxt
faker faker-js fakerjs nuxt nuxt-module
Last synced: 9 months ago
JSON representation
Faker wrapper for Nuxt.js
- Host: GitHub
- URL: https://github.com/skyatura/faker-nuxt
- Owner: SkyaTura
- License: gpl-3.0
- Created: 2020-06-29T19:43:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-31T15:19:45.000Z (over 3 years ago)
- Last Synced: 2024-11-15T20:37:58.157Z (about 1 year ago)
- Topics: faker, faker-js, fakerjs, nuxt, nuxt-module
- Language: JavaScript
- Homepage:
- Size: 266 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# faker-nuxt
> [Faker](https://www.npmjs.com/package/@faker-js/faker) wrapper for [Nuxt.js](https://nuxtjs.org/)
[](https://www.npmjs.com/package/faker-nuxt)
[](https://www.npmjs.com/package/@faker-js/faker)



[](https://gitmoji.dev)
## Features
- Inject `$faker` to the context everywhere.
## Setup
1. Add `faker-nuxt` dependency to your project
```bash
npm install --save-dev faker-nuxt # or yarn add --dev faker-nuxt
```
2. Add `faker-nuxt` to the `buildModules` section of `nuxt.config.js`
```js
export default {
buildModules: [
// Simple usage
'faker-nuxt',
// With options
['faker-nuxt', { /* module options */ }]
]
}
```
:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.
### Using top level options
```js
export default {
buildModules: [
'faker-nuxt'
],
faker: {
/* module options */
}
}
```
## Configuration
### Set default locale
You can set a default locale via the `locale` option.
```js
export default {
buildModules: [
'faker-nuxt'
],
faker: {
locale: 'pt_BR',
}
}
```
### Set default seed
You can set a default seed via the `seed` option.
```js
export default {
buildModules: [
'faker-nuxt'
],
faker: {
seed: 'Banana123',
}
}
```
## Usage
### Using inside templates
```html
{{ $faker.lorem.word() }}
```
### Using inside scripts
```html
export default {
data() {
return {
name: this.$faker.fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}')
}
}
}
```