Clerk is the easiest way to add authentication and user management to your Astro application. Add sign up, sign in, and profile management to your Astro application in minutes.
Getting Started
Prerequisites
Astro 3.2 or later
Node.js >=18.17.0 or later
Installation
Add @clerk/astro as a dependency
With npm
npm install @clerk/astro
With yarn
yarn add @clerk/astro
With pnpm
pnpm add @clerk/astro
Build
To build the package locally with the TypeScript compiler, run:
npm run build
To build the package in watch mode, run the following:
npm run dev
Usage
Set environment variables
PUBLIC_CLERK_PUBLISHABLE_KEY=pk_(test|live)_xxxxxxx
CLERK_SECRET_KEY=sk_(test|live)_xxxxxxx
PUBLIC_CLERK_SIGN_IN_URL=/sign-in # update this if sign in page exists on another path
PUBLIC_CLERK_SIGN_UP_URL=/sign-up # update this if sign up page exists on another path
Add the clerk integration in your astro.config.mjs file.
(Optional) Install the @astrojs/react and add the react in your astro.config.mjs file. You only need to perform this action if you are planing to use react with your project or the React features that provided by astro-clerk-auth. Instructions
Install the @astrojs/node package and the node adapter in your astro.config.mjs file. Instructions
Clerk Headless mode (see ClerkJSVariant prop their docs) is a Clerk variant that is focused towards getting smaller bundle sizes. This variant does not include React or any client side components for Clerk (e.g. their signin component). Because of that the bundle size is drastically smaller. On top of that it also lazy loads the JavaScript client side.
In order to use headless mode with this package, change your Astro configuration file to:
import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import node from "@astrojs/node";
- import clerk from "@clerk/astro";+ import clerk from "@clerk/astro/hotload";
export default defineConfig({
integrations: [
react(),
clerk({
+ clerkJSVariant: "headless"
}),
],
output: "server",
adapter: node({
mode: "standalone",
}),
});
Support
You can get in touch with us in any of the following ways:
The npm package @clerk/astro receives a total of 3,374 weekly downloads. As such, @clerk/astro popularity was classified as popular.
We found that @clerk/astro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 8 open source maintainers collaborating on the project.
Package last updated on 22 Jul 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.