Skip to content

Commit 11335d0

Browse files
authored
docs: add getting started nuxt.js example (#2142)
* docs: add getting started nuxt.js example * docs: simplify nuxt getting-started example - Reduce to minimal setup - Update `package.json`, fix `nuxt.config.ts` and remove unused files - Add `README.md` following vue example template and update `examples/getting-started/README.md` with nuxt row
1 parent 6c6eb76 commit 11335d0

7 files changed

Lines changed: 115 additions & 0 deletions

File tree

examples/getting-started/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Minimal examples for integrating SuperDoc into your project. Each example loads
66
|---------|-------------|------|
77
| [react](./react) | React + TypeScript with Vite | [Guide](https://docs.superdoc.dev/getting-started/frameworks/react) |
88
| [vue](./vue) | Vue 3 + TypeScript with Vite | [Guide](https://docs.superdoc.dev/getting-started/frameworks/vue) |
9+
| [nuxt](./nuxt) | Nuxt 4 + TypeScript with Vite | [Guide](https://docs.superdoc.dev/getting-started/frameworks/nuxt) |
910
| [vanilla](./vanilla) | Plain JavaScript with Vite | [Guide](https://docs.superdoc.dev/getting-started/installation) |
1011
| [cdn](./cdn) | Zero build tools — just an HTML file | [Guide](https://docs.superdoc.dev/getting-started/installation) |
1112

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SuperDoc — Nuxt
2+
3+
Minimal Nuxt 4 + TypeScript example.
4+
5+
## Run
6+
7+
```bash
8+
npm install
9+
npm run dev
10+
```
11+
12+
## Learn more
13+
14+
- [Nuxt Integration Guide](https://docs.superdoc.dev/getting-started/frameworks/nuxt)
15+
- [Configuration Reference](https://docs.superdoc.dev/core/superdoc/configuration)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts">
2+
import { SuperDoc } from 'superdoc'
3+
4+
const editor = ref<HTMLDivElement | null>(null);
5+
const file = ref<File | null>(null)
6+
7+
let superdoc: SuperDoc | null = null;
8+
9+
const handleFile = (e: Event) => {
10+
const input = e.target as HTMLInputElement
11+
if (input.files?.[0]) file.value = input.files[0]
12+
}
13+
14+
const initEditor = () => {
15+
if (!editor.value || !file.value) return
16+
superdoc?.destroy()
17+
superdoc = new SuperDoc({
18+
selector: editor.value,
19+
documentMode: 'editing',
20+
document: file.value,
21+
})
22+
}
23+
24+
watch(file, initEditor)
25+
onBeforeUnmount(() => superdoc?.destroy())
26+
</script>
27+
28+
<template>
29+
<div>
30+
<div style="padding: 1rem; background: #f5f5f5">
31+
<input type="file" accept=".docx" @change="handleFile" />
32+
</div>
33+
<ClientOnly>
34+
<div ref="editor" style="height: calc(100vh - 60px); overflow: auto;" />
35+
</ClientOnly>
36+
</div>
37+
</template>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
ssr: false,
4+
css: ['superdoc/style.css'],
5+
compatibilityDate: '2025-07-15',
6+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "superdoc-nuxt-example",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"dev": "nuxt dev",
7+
"postinstall": "nuxt prepare"
8+
},
9+
"dependencies": {
10+
"nuxt": "^4.3.1",
11+
"superdoc": "latest",
12+
"vue": "^3.5.28"
13+
}
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"files": [],
4+
"references": [
5+
{
6+
"path": "./.nuxt/tsconfig.app.json"
7+
},
8+
{
9+
"path": "./.nuxt/tsconfig.server.json"
10+
},
11+
{
12+
"path": "./.nuxt/tsconfig.shared.json"
13+
},
14+
{
15+
"path": "./.nuxt/tsconfig.node.json"
16+
}
17+
]
18+
}

0 commit comments

Comments
 (0)