kysely-libsql icon indicating copy to clipboard operation
kysely-libsql copied to clipboard

How to use this with the capacitor libsql plugin?

Open kzroo opened this issue 4 months ago • 0 comments

https://capawesome.io/plugins/libsql/

looking at their usage, first few lines:

import { Libsql } from '@capawesome/capacitor-libsql';

const connectToLocalDatabase = async () => {
  const { connectionId } = await Libsql.connect({
    path: 'database.db',
  });
  console.log('Connected to database with ID:', connectionId);
};

const connectToRemoteDatabase = async () => {
  const { connectionId } = await Libsql.connect({
    url: 'libsql://your-database-url.turso.io',
    authToken: 'your-auth-token',
  });
  console.log('Connected to remote database with ID:', connectionId);
};

So the question is: How do we use this in this kysely dialect? The usage here in this package:

const db = new Kysely<Database>({
    dialect: new LibsqlDialect({
        url: "libsql://localhost:8080?tls=0",
        authToken: "<token>", // optional
    }),
});

OR

const client = createClient({
    url: "libsql://localhost:8080",
});

const db = new Kysely<Database>({
    dialect: new LibsqlDialect({ client }),
});

// after you are done with the `db`, you must close the `client`:
client.close();

Would really appreciate it if somebody could shed some light here.

EDIT: I think there needs to be a separate CapacitorLibsqlDialect ...

kzroo avatar Aug 21 '25 19:08 kzroo