Skip to content

Commit c435618

Browse files
RihanArfanatinuxbenjamincanacvercel[bot]
authored
feat: use @nuxthub/core (#69)
Co-authored-by: Sébastien Chopin <[email protected]> Co-authored-by: Benjamin Canac <[email protected]> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
1 parent cc61901 commit c435618

File tree

23 files changed

+1931
-884
lines changed

23 files changed

+1931
-884
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Full-featured AI Chatbot Nuxt application with authentication, chat history, mul
2020
- ⚡️ **Streaming AI messages** powered by the [AI SDK v5](https://sdk.vercel.ai)
2121
- 🤖 **Multiple model support** via various AI providers with built-in AI Gateway support
2222
- 🔐 **Authentication** via [nuxt-auth-utils](https://github.com/atinux/nuxt-auth-utils)
23-
- 💾 **Chat history persistence** using PostgreSQL database and [Drizzle ORM](https://orm.drizzle.team)
23+
- 💾 **Chat history persistence** using SQLite database (Turso in production) and [Drizzle ORM](https://orm.drizzle.team)
2424
- 🚀 **Easy deploy** to Vercel with zero configuration
2525

2626
## Quick Start
@@ -31,7 +31,7 @@ npm create nuxt@latest -- -t ui/chat
3131

3232
## Deploy your own
3333

34-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-name=chat&repository-url=https%3A%2F%2Fgithub.com%2Fnuxt-ui-templates%2Fchat&env=NUXT_SESSION_PASSWORD,NUXT_OAUTH_GITHUB_CLIENT_ID,NUXT_OAUTH_GITHUB_CLIENT_SECRET&products=%5B%7B%22type%22%3A%22integration%22%2C%22group%22%3A%22postgres%22%7D%5D&demo-image=https%3A%2F%2Fui.nuxt.com%2Fassets%2Ftemplates%2Fnuxt%2Fchat-dark.png&demo-url=https%3A%2F%2Fchat-template.nuxt.dev%2F&demo-title=Nuxt%20Chat%20Template&demo-description=An%20AI%20chatbot%20template%20to%20build%20your%20own%20chatbot%20powered%20by%20Nuxt%20MDC%20and%20Vercel%20AI%20SDK.)
34+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-name=chat&repository-url=https%3A%2F%2Fgithub.com%2Fnuxt-ui-templates%2Fchat&env=NUXT_SESSION_PASSWORD,NUXT_OAUTH_GITHUB_CLIENT_ID,NUXT_OAUTH_GITHUB_CLIENT_SECRET&products=%5B%7B%22type%22%3A%22integration%22%2C%22protocol%22%3A%22storage%22%2C%22productSlug%22%3A%22database%22%2C%22integrationSlug%22%3A%22tursocloud%22%7D%5D&demo-image=https%3A%2F%2Fui.nuxt.com%2Fassets%2Ftemplates%2Fnuxt%2Fchat-dark.png&demo-url=https%3A%2F%2Fchat-template.nuxt.dev%2F&demo-title=Nuxt%20Chat%20Template&demo-description=An%20AI%20chatbot%20template%20to%20build%20your%20own%20chatbot%20powered%20by%20Nuxt%20MDC%20and%20Vercel%20AI%20SDK.)
3535

3636
## Setup
3737

@@ -102,10 +102,8 @@ Or connect your repository to Vercel for automatic deployments:
102102
1. Push your code to GitHub
103103
2. Connect your repository to [Vercel](https://vercel.com)
104104
3. Configure your environment variables in the Vercel dashboard
105-
4. Deploy automatically on every push
106-
107-
> [!NOTE]
108-
> Make sure to configure your PostgreSQL database connection and run migrations in your production environment.
105+
4. Create a Turso database and connect it to your Vercel project
106+
5. Deploy automatically on every push
109107

110108
The application is configured to use [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) which provides:
111109

app/composables/useChats.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { isToday, isYesterday, subMonths } from 'date-fns'
22

3-
interface Chat {
3+
export interface UIChat {
44
id: string
55
label: string
66
icon: string
77
createdAt: string
88
}
99

10-
export function useChats(chats: Ref<Chat[] | undefined>) {
10+
export function useChats(chats: Ref<UIChat[] | undefined>) {
1111
const groups = computed(() => {
1212
// Group chats by date
13-
const today: Chat[] = []
14-
const yesterday: Chat[] = []
15-
const lastWeek: Chat[] = []
16-
const lastMonth: Chat[] = []
17-
const older: Record<string, Chat[]> = {}
13+
const today: UIChat[] = []
14+
const yesterday: UIChat[] = []
15+
const lastWeek: UIChat[] = []
16+
const lastMonth: UIChat[] = []
17+
const older: Record<string, UIChat[]> = {}
1818

1919
const oneWeekAgo = subMonths(new Date(), 0.25) // ~7 days ago
2020
const oneMonthAgo = subMonths(new Date(), 1)
@@ -56,7 +56,7 @@ export function useChats(chats: Ref<Chat[] | undefined>) {
5656
const formattedGroups = [] as Array<{
5757
id: string
5858
label: string
59-
items: Array<Chat>
59+
items: Array<UIChat>
6060
}>
6161

6262
// Add groups that have chats

app/pages/chat/[id].vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ const { model } = useModels()
1919
const { data } = await useFetch(`/api/chats/${route.params.id}`, {
2020
cache: 'force-cache'
2121
})
22-
2322
if (!data.value) {
24-
throw createError({ statusCode: 404, statusMessage: 'Chat not found', fatal: true })
23+
throw createError({ statusCode: 404, statusMessage: 'Chat not found' })
2524
}
2625
2726
const input = ref('')

drizzle.config.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

nuxt.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineNuxtConfig({
44
'@nuxt/eslint',
55
'@nuxt/ui',
66
'@nuxtjs/mdc',
7+
'@nuxthub/core',
78
'nuxt-auth-utils',
89
'nuxt-charts'
910
],
@@ -36,6 +37,10 @@ export default defineNuxtConfig({
3637
}
3738
},
3839

40+
hub: {
41+
db: 'sqlite'
42+
},
43+
3944
eslint: {
4045
config: {
4146
stylistic: {

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
"postinstall": "nuxt prepare",
1010
"lint": "eslint .",
1111
"typecheck": "nuxt typecheck",
12-
"db:generate": "drizzle-kit generate",
13-
"db:migrate": "drizzle-kit migrate"
12+
"db:generate": "nuxt db generate",
13+
"db:migrate": "nuxt db migrate"
1414
},
1515
"dependencies": {
1616
"@ai-sdk/gateway": "^2.0.15",
1717
"@ai-sdk/vue": "^2.0.101",
1818
"@iconify-json/logos": "^1.2.10",
1919
"@iconify-json/lucide": "^1.2.74",
2020
"@iconify-json/simple-icons": "^1.2.59",
21+
"@libsql/client": "^0.15.15",
2122
"@nuxt/ui": "^4.2.1",
23+
"@nuxthub/core": "^0.10.0",
2224
"@nuxtjs/mdc": "^0.18.4",
2325
"ai": "^5.0.101",
2426
"date-fns": "^4.1.0",
@@ -32,7 +34,7 @@
3234
"devDependencies": {
3335
"@nuxt/eslint": "^1.10.0",
3436
"@types/node": "^24.10.1",
35-
"drizzle-kit": "^0.31.7",
37+
"drizzle-kit": "^0.31.8",
3638
"eslint": "^9.39.1",
3739
"typescript": "^5.9.3",
3840
"vue-tsc": "^3.1.5"

0 commit comments

Comments
 (0)