mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Rename stack -> hexclave in docs, and one place in data-vault example on dashboard.
Some checks failed
DB migration compat / Check if migrations changed (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
Some checks failed
DB migration compat / Check if migrations changed (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
This commit is contained in:
parent
9162767c5c
commit
b1d9f6db40
@ -137,7 +137,7 @@ export default function PageClient({ storeId }: PageClientProps) {
|
||||
|
||||
const serverExample = deindent`
|
||||
// In your .env file or environment variables:
|
||||
// STACK_DATA_VAULT_SECRET=insert-a-randomly-generated-secret-here
|
||||
// HEXCLAVE_DATA_VAULT_SECRET=insert-a-randomly-generated-secret-here
|
||||
|
||||
const store = await hexclaveServerApp.getDataVaultStore(${JSON.stringify(storeId)});
|
||||
|
||||
@ -146,12 +146,12 @@ export default function PageClient({ storeId }: PageClientProps) {
|
||||
|
||||
// Get a value for a specific key
|
||||
const value = await store.getValue(key, {
|
||||
secret: process.env.STACK_DATA_VAULT_SECRET,
|
||||
secret: process.env.HEXCLAVE_DATA_VAULT_SECRET,
|
||||
});
|
||||
|
||||
// Set a value for a specific key
|
||||
await store.setValue(key, "my-value", {
|
||||
secret: process.env.STACK_DATA_VAULT_SECRET,
|
||||
secret: process.env.HEXCLAVE_DATA_VAULT_SECRET,
|
||||
});
|
||||
`;
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ Next, we can create a hook/function to check if the user has completed onboardin
|
||||
</Tab>
|
||||
<Tab title="Server Component">
|
||||
```jsx
|
||||
import { hexclaveServerApp } from '@/stack/server';
|
||||
import { hexclaveServerApp } from '@/hexclave/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export async function ensureOnboarded() {
|
||||
@ -108,7 +108,7 @@ You can then use these functions wherever onboarding is required:
|
||||
<Tab title="Server Component">
|
||||
```jsx
|
||||
import { ensureOnboarding } from '@/app/onboarding-functions';
|
||||
import { hexclaveServerApp } from '@/stack/server';
|
||||
import { hexclaveServerApp } from '@/hexclave/server';
|
||||
|
||||
export default async function HomePage() {
|
||||
await ensureOnboarding();
|
||||
|
||||
@ -14,7 +14,7 @@ Follow these steps when you're ready to push your application to production:
|
||||
|
||||
<Steps>
|
||||
<Step title="Add Your Domain">
|
||||
Navigate to the `Domain & Handlers` tab in the Hexclave dashboard. If you haven't configured your handler, you can leave it as the default. (Learn more about handlers [here](/sdk/objects/stack-app)).
|
||||
Navigate to the `Domain & Handlers` tab in the Hexclave dashboard. If you haven't configured your handler, you can leave it as the default. (Learn more about handlers [here](/sdk/objects/hexclave-app)).
|
||||
</Step>
|
||||
<Step title="Disable Localhost Callbacks">
|
||||
For enhanced security, disable the `Allow all localhost callbacks for development` option.
|
||||
|
||||
@ -32,7 +32,7 @@ The `createCheckoutUrl` method is available on both user and team objects.
|
||||
</Tab>
|
||||
<Tab title="Server Component">
|
||||
```typescript title="app/purchase/page.tsx"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export default async function PurchasePage() {
|
||||
const user = await hexclaveServerApp.getUser({ or: 'redirect' });
|
||||
|
||||
@ -8,6 +8,8 @@ Sometimes you need to give a customer a product without charging them - free tri
|
||||
## Granting a configured product
|
||||
|
||||
```typescript
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
// Grant a pre-configured product to a user
|
||||
await hexclaveServerApp.grantProduct({
|
||||
userId: "user-id",
|
||||
@ -34,6 +36,8 @@ If you already have a reference to a **server** user or team object (for example
|
||||
You can also grant products with an **inline definition** - no pre-configured product needed. This is useful for one-off grants like bonus credits:
|
||||
|
||||
```typescript
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
await hexclaveServerApp.grantProduct({
|
||||
userId: "user-id",
|
||||
product: {
|
||||
|
||||
@ -50,7 +50,7 @@ export default function CreditsWidget() {
|
||||
When your app needs to consume credits (e.g. when a user sends an AI request), use `tryDecreaseQuantity` on the server. It's a single transactional operation - it returns `false` and does nothing if the balance would go negative, so concurrent requests can't overspend.
|
||||
|
||||
```typescript title="lib/credits.ts"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export async function consumeCredits(userId: string, amount: number) {
|
||||
const user = await hexclaveServerApp.getUser(userId);
|
||||
|
||||
@ -57,6 +57,8 @@ export default function UpgradeButton() {
|
||||
</Tab>
|
||||
<Tab title="Server">
|
||||
```typescript
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
// Cancel for the current user
|
||||
await hexclaveServerApp.cancelSubscription({ productId: "prod_pro" });
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ If you have not installed Stack yet (handler routes, `HexclaveProvider`, environ
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Hexclave installed as in [Build a SaaS with Hexclave](/guides/other/tutorials/build-a-saas-with-hexclave) (Next.js App Router examples below assume `hexclaveServerApp` in `stack/server.ts` and `@hexclave/next` in the app).
|
||||
- Hexclave installed as in [Build a SaaS with Hexclave](/guides/other/tutorials/build-a-saas-with-hexclave) (Next.js App Router examples below assume `hexclaveServerApp` in `hexclave/server.ts` and `@hexclave/next` in the app).
|
||||
- A project in the [dashboard](https://app.hexclave.com/projects) where you can edit **Teams** and **Team permissions**.
|
||||
|
||||
<Note>
|
||||
@ -42,7 +42,7 @@ Use the **current user** as the scope: `listTeams` / `useTeams`, and `getTeam` /
|
||||
<Tab title="Server Component">
|
||||
```tsx title="app/team/[teamId]/page.tsx"
|
||||
import Link from "next/link";
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
type PageProps = { params: { teamId: string } };
|
||||
|
||||
@ -101,7 +101,7 @@ If your framework types route `params` as a `Promise` (newer Next.js), `await` t
|
||||
<Tab title="Server">
|
||||
```tsx title="app/team/page.tsx"
|
||||
import Link from "next/link";
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export default async function TeamsIndexPage() {
|
||||
const user = await hexclaveServerApp.getUser({ or: "redirect" });
|
||||
@ -179,7 +179,7 @@ export function CreateWorkspaceButton() {
|
||||
For imports, support tools, or other **server** jobs, `hexclaveServerApp.createTeam` creates a team at project scope (see [Teams](/guides/apps/teams/overview)); wire membership separately if your flow requires it.
|
||||
|
||||
```tsx title="scripts/provision-team.example.ts"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export async function provisionEmptyTeam(displayName: string) {
|
||||
return await hexclaveServerApp.createTeam({ displayName });
|
||||
@ -226,7 +226,7 @@ Replace `export_reports` with a permission you created.
|
||||
<Tabs>
|
||||
<Tab title="Server Component">
|
||||
```tsx title="app/team/[teamId]/reports/page.tsx"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
type PageProps = { params: { teamId: string } };
|
||||
|
||||
@ -289,7 +289,7 @@ For listing effective permissions, use `listPermissions` / `usePermissions` ([RB
|
||||
```tsx title="app/actions/reports.ts"
|
||||
"use server";
|
||||
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export async function requestReportExportAction(teamId: string) {
|
||||
const user = await hexclaveServerApp.getUser({ or: "throw" });
|
||||
|
||||
@ -27,7 +27,7 @@ You typically combine **one or more** of:
|
||||
<Tab title="Middleware (route prefix)">
|
||||
```tsx title="middleware.ts"
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
const user = await hexclaveServerApp.getUser();
|
||||
@ -48,7 +48,7 @@ You typically combine **one or more** of:
|
||||
</Tab>
|
||||
<Tab title="Server Component">
|
||||
```tsx title="app/app/dashboard/page.tsx"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
|
||||
export default async function DashboardPage() {
|
||||
await hexclaveServerApp.getUser({ or: "redirect" });
|
||||
@ -76,7 +76,7 @@ You typically combine **one or more** of:
|
||||
- **`{ or: "throw" }`** — use in **server actions**, **route handlers**, and other places where redirecting would be wrong; map errors to `401`/`403` responses yourself.
|
||||
|
||||
```tsx title="app/api/me/route.ts"
|
||||
import { hexclaveServerApp } from "@/stack/server";
|
||||
import { hexclaveServerApp } from "@/hexclave/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user