A minimal starter for ATProto logins in Astro
1# Astro ATProto OAuth Starter 2 3A minimal [Astro](https://astro.build) starter template demonstrating OAuth authentication with AT Protocol (ATProto), the decentralized social networking protocol used by Bluesky and other services. 4 5This starter includes: 6- Complete OAuth authentication flow using `@atproto/oauth-client-node` 7- Cookie-based session management 8- Profile display after authentication 9- Login/logout endpoints 10- Tailwind CSS and DaisyUI styling 11 12## 🚀 Getting Started 13 141. **Install dependencies:** 15 ```sh 16 npm install 17 ``` 18 192. **Configure environment variables:** 20 ```sh 21 cp .env.template .env 22 ``` 23 Edit `.env` if you need to change the port (default: 4321) or set a public URL. 24 253. **Start the development server:** 26 ```sh 27 npm run dev 28 ``` 29 The app will be available at `http://localhost:4321` 30 314. **Try logging in:** 32 Enter your AT Protocol handle (e.g., `alice.bsky.social`) to authenticate. 33 34## 📁 Project Structure 35 36```text 37/ 38├── public/ 39├── src/ 40│ ├── lib/ 41│ │ ├── context.ts # OAuth client singleton 42│ │ ├── oauth.ts # OAuth client configuration 43│ │ ├── session.ts # Session management 44│ │ └── storage.ts # Cookie-based stores 45│ ├── pages/ 46│ │ ├── api/ 47│ │ │ ├── login.ts # Login endpoint 48│ │ │ ├── logout.ts # Logout endpoint 49│ │ │ └── oauth/ 50│ │ │ └── callback.ts # OAuth callback handler 51│ │ └── index.astro # Main page with login UI 52│ └── styles.css 53└── package.json 54``` 55 56## 🧞 Commands 57 58All commands are run from the root of the project, from a terminal: 59 60| Command | Action | 61| :------------------------ | :----------------------------------------------- | 62| `npm install` | Installs dependencies | 63| `npm run dev` | Starts local dev server at `localhost:4321` | 64| `npm run build` | Build your production site to `./dist/` | 65| `npm run preview` | Preview your build locally, before deploying | 66| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | 67| `npm run astro -- --help` | Get help using the Astro CLI | 68 69## 📚 Learn More 70 71- [Astro Documentation](https://docs.astro.build) 72- [AT Protocol Documentation](https://atproto.com) 73- [@atproto/oauth-client-node](https://github.com/bluesky-social/atproto/tree/main/packages/oauth/oauth-client-node) 74- [Bluesky](https://bsky.app)