This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add
app-config
example (#7247)
Co-authored-by: Pooya Parsa <[email protected]>
- Loading branch information
Showing
6 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
template: Example | ||
--- | ||
|
||
# `app.config` | ||
|
||
> Nuxt 3 provides an app.config config file to expose reactive configuration within your application with the ability to update it at runtime within lifecycle or using a nuxt plugin and editing it with HMR (hot-module-replacement). | ||
This example shows how to use `app.config` feature. | ||
|
||
::ReadMore{link="/guide/features/app-config"} | ||
:: | ||
|
||
::sandbox{repo="nuxt/framework" branch="main" dir="examples/app-config" file="app.vue"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default defineAppConfig({ | ||
title: 'Hello App Config', | ||
description: | ||
'This is some content coming from app.config.ts that support HMR, try to update it and see it in action.', | ||
showButton: false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup> | ||
const config = useAppConfig() | ||
</script> | ||
|
||
<template> | ||
<NuxtExampleLayout example="app-config"> | ||
<h1>{{ config.title }}</h1> | ||
<p>{{ config.description }}</p> | ||
<button v-if="config.showButton"> | ||
I am a button | ||
</button> | ||
</NuxtExampleLayout> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineNuxtConfig } from 'nuxt' | ||
|
||
export default defineNuxtConfig({ | ||
modules: [ | ||
'@nuxt/ui' | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "example-app-config", | ||
"private": true, | ||
"scripts": { | ||
"build": "nuxi build", | ||
"dev": "nuxi dev", | ||
"start": "nuxi preview" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/ui": "^0.2.0", | ||
"nuxt": "npm:nuxt3@latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |