mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- RECURSEML_SUMMARY:START --> ## High-level PR Summary This PR implements a comprehensive renaming of "offer" to "product" and "offer group" to "product catalog" throughout the codebase. The changes include database migrations, schema updates, API compatibility layers, function renames, and updates to client and server implementations. Backwards compatibility is maintained through migration layers that handle requests using the old terminology, translating them to the new terminology before processing. The PR includes documentation of this approach in CLAUDE-KNOWLEDGE.md. This rename affects multiple parts of the system including the database schema, API endpoints, error types, and SDK interfaces. ⏱️ Estimated Review Time: 1-3 hours <details> <summary>💡 Review Order Suggestion</summary> | Order | File Path | |-------|-----------| | 1 | `apps/backend/prisma/migrations/20250923191615_rename_offers_to_products/migration.sql` | | 2 | `apps/backend/src/app/api/migrations/v2beta1/payments/purchases/offers-compat.ts` | | 3 | `apps/backend/src/app/api/migrations/v2beta1/payments/purchases/create-purchase-url/route.ts` | | 4 | `apps/backend/src/app/api/migrations/v2beta1/payments/purchases/validate-code/route.ts` | | 5 | `apps/backend/src/lib/payments.tsx` | | 6 | `.claude/CLAUDE-KNOWLEDGE.md` | | 7 | `packages/stack-shared/src/schema-fields.ts` | | 8 | `packages/stack-shared/src/known-errors.tsx` | | 9 | `packages/stack-shared/src/config/schema.ts` | | 10 | `packages/template/src/lib/stack-app/customers/index.ts` | | 11 | `packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts` | | 12 | `packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts` | </details> [](https://discord.gg/n3SsVDAW6U) <!-- RECURSEML_SUMMARY:END --> <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Renames 'offer' to 'product' and 'offer group' to 'product catalog' across the codebase, updating database schema, API endpoints, and application logic for consistency and backward compatibility. > > - **Database**: > - Rename columns `offer` to `product` and `offerId` to `productId` in `OneTimePurchase` and `Subscription` tables in `migration.sql`. > - **API & Migrations**: > - Update API endpoints to accept `product_id`/`product_inline` instead of `offer_id`/`offer_inline`. > - Add `v2beta5` compatibility layer to map legacy `offer` fields to `product` equivalents. > - **Shared Schemas**: > - Rename `offerSchema` to `productSchema` and related schemas in `schema-fields.ts`. > - **Server Implementation**: > - Update `createCheckoutUrl` method in `server-app-impl.ts` to use `productId`/`InlineProduct`. > - **Tests**: > - Update tests to reflect renaming in `backend-helpers.ts` and other test files. > - **Miscellaneous**: > - Remove dummy data related to offers in `dummy-data.tsx`. > - Update documentation and comments to reflect terminology changes. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup> fore3227bcbd2. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> ---- <!-- ELLIPSIS_HIDDEN --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Backwards-compatibility: legacy offer_id/offer_inline requests are accepted, normalized, and routed to product-based handlers. * **Refactor** * Global rename from Offer/Group → Product/Catalog across UI, APIs, types, client/server interfaces, and error codes. * **Bug Fixes** * Responses, webhooks and UI consistently surface product_display_name and product-related metadata. * **Documentation** * Migration notes and docs updated to explain compatibility and parameter changes. * **Tests** * Unit and E2E suites updated to cover product/catalog flows. * **Chores** * Database schema migration, seed and config updates applied. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Renames offers→products and groups→catalogs end-to-end (DB, APIs, schemas, UI, SDK, docs), adding v2beta5 compatibility to accept legacy offer fields while updating all internals. > > - **Backend/DB**: > - Prisma migration: rename `offer`/`offerId`→`product`/`productId` in `OneTimePurchase` and `Subscription`. > - Update Stripe webhook, purchase-session, and internal test-mode flows to use `product*` metadata/fields. > - **API & Migrations**: > - Latest endpoints now accept `product_id`/`product_inline`. > - Add `v2beta5` compat layer mapping legacy `offer_id`/`offer_inline` to product equivalents; responses alias conflicting products. > - **Shared Schemas/Errors/Config**: > - `offerSchema`→`productSchema`, `inlineOfferSchema`→`inlineProductSchema`, prices/types renamed. > - KnownErrors renamed (e.g., `PRODUCT_DOES_NOT_EXIST`). > - Config: `groups`→`catalogs`, defaults/migrations updated; improved override validation messages; ID regex loosened; formatter tweaks; add schema fuzzer tests. > - **Payments Lib**: > - Rename APIs and logic (`offers`→`products`, `groupId`→`catalogId`), subscription and item-quantity computation updated. > - **Dashboard/UI**: > - Routes, dialogs, editors, tables, and code samples switched to products/catalogs; removed offers dummy data. > - **SDK/Template**: > - Client/server `createCheckoutUrl` now uses `productId`/`InlineProduct`. > - **Tests/Docs/Utilities**: > - E2E and unit tests updated; add legacy (pre-rename) tests. > - Docs and knowledge base revised; minor script tweaks (recent-first, limits). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commite6e20ecd72. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: BilalG1 <bg2002@gmail.com>
113 lines
4.8 KiB
Plaintext
113 lines
4.8 KiB
Plaintext
---
|
|
title: Overview
|
|
---
|
|
|
|
Welcome to Stack Auth, the developer-friendly open-source authentication platform that gets you started in minutes!
|
|
|
|
You can get started in five minutes with our [setup guide](./getting-started/setup.mdx), or jump straight into the documentation.
|
|
|
|
<CardGroup>
|
|
<Card
|
|
title="Setup & Installation"
|
|
icon="fa-regular fa-play"
|
|
href="./getting-started/setup"
|
|
>
|
|
Get started with Stack in 5 minutes
|
|
</Card>
|
|
{/* IF_PLATFORM: react-like */}
|
|
<Card
|
|
title="Components"
|
|
icon="fa-solid fa-puzzle"
|
|
href="./components"
|
|
>
|
|
Use our pre-built React components, or create your own
|
|
</Card>
|
|
{/* END_PLATFORM */}
|
|
{/* IF_PLATFORM: js-like */}
|
|
<Card
|
|
title="SDK Reference"
|
|
icon="fa-regular fa-file-lines"
|
|
href="./sdk"
|
|
>
|
|
Learn how to use Stack Auth's SDK
|
|
</Card>
|
|
{/* END_PLATFORM */}
|
|
<Card
|
|
title="REST API Reference"
|
|
icon="fa-solid fa-code"
|
|
href="/api/overview"
|
|
>
|
|
Explore Stack's REST APIs
|
|
</Card>
|
|
</CardGroup>
|
|
|
|
Still have questions? Check out our [FAQ](./faq) or [join our Discord](https://discord.stack-auth.com).
|
|
|
|
## Why Choose Stack Auth?
|
|
|
|
Authentication is inherently difficult. Few things are more sensitive than user data and more complex than cryptography. Not surprisingly, many online businesses struggle to get it right.
|
|
|
|
The optimal authentication solution should be secure, yet approachable. If developers need to worry about JWTs, OAuth flows, or password hashing, then the authentication solution has failed its purpose. If an authentication solution uses closed-source, unauditable code for the most critical parts of your application, then we have failed.
|
|
|
|
In truth, the authentication services industry has collectively failed. It's dominated by proprietary giants with predatory "bait-and-switch" pricing, providing no transparency into their codebase and delivering a subpar developer experience — because they know enterprises will pay more if setting up auth systems is painful.
|
|
|
|
That's why we built Stack Auth. Integrating secure authentication into your app should take **5 minutes**, not 5 days.
|
|
|
|
At the core of Stack Auth are deep integrations into frontend and backend frameworks. We product the best developer experience with Next.js. Instead of providing mediocre support for numerous frameworks, we focused on making a few integrations excellent before adding new ones. We also product a cross-compatible REST API as a fallback.
|
|
|
|
Here's an example. To get the current user, simply call:
|
|
|
|
```tsx
|
|
export function MyComponent() {
|
|
const user = useUser({ or: "redirect" });
|
|
return <div>Hi, {user.displayName}</div>;
|
|
}
|
|
```
|
|
|
|
That's it! Stack Auth will either return a User object or redirect the user to the login page.
|
|
|
|
You can also add a button to change the user's name:
|
|
|
|
```tsx
|
|
<button onClick={async () => await user.update({ displayName: "New Name" })}>
|
|
Change Name
|
|
</button>
|
|
```
|
|
|
|
The user data will update in both the frontend and backend automatically. The updated user data will be reflected in all other components on your page as well.
|
|
|
|
You also get pages and components for the authentication flow out-of-the-box. This is the sign-in page you get without writing a single line of code:
|
|
|
|
<div className="stack-white-image-showcase stack-350h">
|
|
<img src="/imgs/sign-in.png" alt="SignIn" />
|
|
</div>
|
|
|
|
Notice, there's no branding on our components. We believe we should grow by building the best product, not by forcing our brand onto your users. This means **we depend on your help to spread the word about Stack**. If you like what you're reading, please take a moment to tell one or two of your friends about us.
|
|
|
|
If you prefer a fully customized UI, you can use our low-level functions like `signInWithOAuth` or `signInWithCredential` to build your own sign-in page:
|
|
|
|
```tsx
|
|
export default function CustomOAuthSignIn() {
|
|
const app = useStackApp();
|
|
return (
|
|
<div>
|
|
<button onClick={async () => await app.signInWithOAuth('google')}>
|
|
Sign In with Google
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|
|
```
|
|
|
|
To manage everything efficiently, there is a powerful admin dashboard:
|
|
|
|

|
|
|
|
Best of all, Stack Auth is **100% open-source**. This means the client, server, dashboard, and even this documentation you're reading right now. Check out our [GitHub](https://github.com/stack-auth/stack-auth) to open an issue or pull request.
|
|
|
|
This is just a glimpse of what Stack Auth can do. We also handle many other tasks like backend integration, data storage, emails, teams, permissions, and more, which you will learn about later in the documentation.
|
|
|
|
If this sounds interesting, [get started](./getting-started/setup) with our interactive setup wizard, or join [our Discord community](https://discord.stack-auth.com) to ask questions and get help from our team.
|
|
|
|
We're excited to have you on board! 🚀
|