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_ASTRO_APP_CLERK_PUBLISHABLE_KEY=pk_(test|live)_xxxxxxx
CLERK_SECRET_KEY=sk_(test|live)_xxxxxxx
PUBLIC_ASTRO_APP_CLERK_SIGN_IN_URL=/sign-in # update this if sign in page exists on another path
PUBLIC_ASTRO_APP_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 1,079 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 0 open source maintainers collaborating on the project.
Package last updated on 04 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.
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
A malicious npm campaign is targeting Ethereum developers by impersonating Hardhat plugins and the Nomic Foundation, stealing sensitive data like private keys.