Use the hosted service

The quickest path. The hosted service at palmshed-auth.vercel.app runs the API; your page only needs the client.

<script type="module">
  import { AuthClient } from "https://cdn.jsdelivr.net/npm/@palmshed/auth-client@1/dist/index.js";

  const client = new AuthClient({ baseUrl: "https://palmshed-auth.vercel.app" });

  const result = await client.signIn("alice", "password");
  if (result.ok) {
    console.log("Signed in as", result.data.user.username);
  }
</script>

For production, vendor the built client into your assets so your page does not depend on a CDN at runtime. The palmshed.github.io site does this and is the reference.

Run the fullstack template

For a self-hosted application with a login page and a database, copy templates/fullstack from the repository.

cp -r templates/fullstack my-app
cd my-app
npm install
cp .env.example .env   # set DATABASE_URL
npm run dev

The server serves the sign-in page and the API from the same origin. See Deployment.

Embed the packages

For full control, add the packages to your own server and database.

npm install @palmshed/auth-core @palmshed/auth-hono @palmshed/auth-storage-postgres
import { Auth } from "@palmshed/auth-core";
import { PostgresStorage } from "@palmshed/auth-storage-postgres";
import { middleware, createHandlers } from "@palmshed/auth-hono";

const storage = new PostgresStorage(process.env.DATABASE_URL);
await storage.migrate();

const auth = new Auth({ storage, config: {} });

See Server for the full setup and examples/ for runnable Express, Hono, and React integrations.