A minimal starter for ATProto logins in Astro
TypeScript 63.6%
Astro 30.0%
JavaScript 4.1%
CSS 1.0%
Other 1.2%
5 1 0

Clone this repository

https://tangled.org/daffl.xyz/astro-atproto-starter
git@knot.commonscomputer.com:daffl.xyz/astro-atproto-starter

For self-hosted knots, clone URLs may differ based on your setup.

README.md

Astro ATProto OAuth Starter#

A minimal Astro starter template demonstrating OAuth authentication with AT Protocol (ATProto), the decentralized social networking protocol used by Bluesky and other services.

This starter includes:

  • Complete OAuth authentication flow using @atproto/oauth-client-node
  • Cookie-based session management
  • Profile display after authentication
  • Login/logout endpoints
  • Tailwind CSS and DaisyUI styling

🚀 Getting Started#

  1. Install dependencies:

    npm install
    
  2. Configure environment variables:

    cp .env.template .env
    

    Edit .env if you need to change the port (default: 4321) or set a public URL.

  3. Start the development server:

    npm run dev
    

    The app will be available at http://localhost:4321

  4. Try logging in: Enter your AT Protocol handle (e.g., alice.bsky.social) to authenticate.

📁 Project Structure#

/
├── public/
├── src/
│   ├── lib/
│   │   ├── context.ts      # OAuth client singleton
│   │   ├── oauth.ts        # OAuth client configuration
│   │   ├── session.ts      # Session management
│   │   └── storage.ts      # Cookie-based stores
│   ├── pages/
│   │   ├── api/
│   │   │   ├── login.ts    # Login endpoint
│   │   │   ├── logout.ts   # Logout endpoint
│   │   │   └── oauth/
│   │   │       └── callback.ts  # OAuth callback handler
│   │   └── index.astro     # Main page with login UI
│   └── styles.css
└── package.json

🧞 Commands#

All commands are run from the root of the project, from a terminal:

Command Action
npm install Installs dependencies
npm run dev Starts local dev server at localhost:4321
npm run build Build your production site to ./dist/
npm run preview Preview your build locally, before deploying
npm run astro ... Run CLI commands like astro add, astro check
npm run astro -- --help Get help using the Astro CLI

📚 Learn More#