Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/content/2.guide/2.directory-structure/3.app.config.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ declare module '@nuxt/schema' {
// It is always important to ensure you import/export something when augmenting a type
export {}
```

## Defining Custom Root Element

By default, Nuxt will mount your app inside a `#__nuxt` container. You may choose to customize the root element by defining another selector in your app config.

**Example:**

```ts [app.config.ts]
export default defineAppConfig({
el: '#some-other-container'
})
```
5 changes: 4 additions & 1 deletion packages/nuxt/src/app/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '#build/css'
import _plugins from '#build/plugins'
// @ts-ignore
import RootComponent from '#build/root-component.mjs'
// @ts-ignore
import appConfig from '#build/app.config.mjs'

if (!globalThis.$fetch) {
// @ts-ignore
Expand Down Expand Up @@ -64,7 +66,8 @@ if (process.client) {
try {
await nuxt.hooks.callHook('app:created', vueApp)
await nuxt.hooks.callHook('app:beforeMount', vueApp)
vueApp.mount('#__nuxt')
const el = appConfig.el ?? '#__nuxt'
vueApp.mount(el)
await nuxt.hooks.callHook('app:mounted', vueApp)
await nextTick()
} catch (err) {
Expand Down