tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.54k stars 252 forks source link

Having trouble syncing in Nuxt3 – Embedded Syncs works with Nuxt x Vercel? #1689

Open mavichow opened 1 month ago

mavichow commented 1 month ago

I've cloned, tested and deploy Nuxt3 to Vercel with this repo: https://github.com/tursodatabase/examples/tree/master/app-top-web-frameworks

Everything works well with remote DB and when I tried to embed the db locally, the replica.db seems like it's empty.

May I know did I missed out any steps?


// server/utils/turso.ts
import { createClient } from "@libsql/client";

export function useTurso() {
  const tursoConfig = useRuntimeConfig().turso;

  if (!tursoConfig.dbUrl || !tursoConfig.dbAuthToken) {
    throw new Error(
      "Please fill the NUXT_TURSO_DB_URL and NUXT_TURSO_DB_AUTH_TOKEN env variables"
    );
  }
  return createClient({
    url : "file:dbs/replica.db",
    syncUrl: tursoConfig.dbUrl,
    authToken: tursoConfig.dbAuthToken,
  });
}
`