@youasked/react 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aden Teo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # @youasked/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Feature requests your users can vote on, built into your React app. People ask and vote without leaving the app, you hear about it on your phone, and everyone who asked is told when it ships.
4
+
5
+ Site and live demo: https://youasked.adenteo.workers.dev
6
+
7
+ ## Set up
8
+
9
+ The quickest way is to run this in your project root. It creates the app, writes the keys and adds the components you pick:
10
+
11
+ ```sh
12
+ npx youasked init
13
+ ```
14
+
15
+ Or by hand:
16
+
17
+ ```sh
18
+ npm i @youasked/react
19
+ ```
20
+
21
+ ```tsx
22
+ "use client";
23
+ import { YouAsked } from "@youasked/react";
24
+
25
+ export function FeatureRequests({ children }: { children: React.ReactNode }) {
26
+ return <YouAsked appKey={process.env.NEXT_PUBLIC_YOUASKED_KEY!}>{children}</YouAsked>;
27
+ }
28
+ ```
29
+
30
+ `trigger="floating"` (the default) adds a chat bubble in the corner. Use `trigger="none"` and the entry points below if you'd rather place it yourself.
31
+
32
+ ## Entry points
33
+
34
+ All of them open the same sheet, in your colours, font and dark mode.
35
+
36
+ | Component | Use it for |
37
+ |---|---|
38
+ | `<AskBar />` | A chat-style input on a home screen |
39
+ | `<FeatureCard />` | Top requests with vote buttons on a dashboard |
40
+ | `<RequestButton variant="icon" />` | A round header button, with a badge when something ships |
41
+ | `<RequestButton variant="row" />` | A settings row |
42
+ | `<RequestButton variant="pill" />` | A tinted pill anywhere |
43
+ | `<AskAbout topic="charts" />` | A quiet prompt next to a feature |
44
+ | `<AskForIt query={search} />` | An empty search result that offers to ask for it |
45
+ | `<FeatureBoard />` | Everything inline, for a `/feedback` page |
46
+ | `useYouAsked().open({ view: "new", draft: "Export to Excel" })` | Any button, such as a locked feature |
47
+
48
+ ## Signed-in users
49
+
50
+ Without this, visitors are anonymous (one ID per device). With sign-in, sign the user ID on your server so nobody can vote as someone else:
51
+
52
+ ```ts
53
+ // app/api/youasked/identity/route.ts
54
+ import { signUser } from "@youasked/react/server";
55
+
56
+ export async function GET() {
57
+ const user = await getCurrentUser(); // your auth
58
+ if (!user) return Response.json({ error: "Unauthorized" }, { status: 401 });
59
+ return Response.json({ userId: user.id, signature: await signUser(process.env.YOUASKED_SECRET_KEY!, user.id) });
60
+ }
61
+ ```
62
+
63
+ Then pass `user={{ id: userId }} signature={signature} ready={loaded}` to `<YouAsked>`. Never put `YOUASKED_SECRET_KEY` in client code.
64
+
65
+ ## Theming
66
+
67
+ It reads shadcn tokens (`--primary`, `--background`, `--radius` and so on) on its own. Otherwise pass `appearance`:
68
+
69
+ ```tsx
70
+ <YouAsked appKey="ya_pub_…" appearance={{ accent: "#5b3df5", radius: 16, fontFamily: "inherit" }} />
71
+ ```
72
+
73
+ Dark mode follows the page's `.dark` class or `data-theme`.
74
+
75
+ ## Shipping
76
+
77
+ Connect Telegram, Slack, Discord or GitHub from the dashboard. A commit with `closes YA-12` on your default branch marks request YA-12 shipped and tells everyone who asked. To let your coding agent read and ship requests, add the MCP server:
78
+
79
+ ```sh
80
+ claude mcp add youasked -e YOUASKED_SECRET_KEY=ya_sec_… -- npx -y @youasked/mcp
81
+ ```
82
+
83
+ ## License
84
+
85
+ MIT
@@ -0,0 +1,40 @@
1
+ import { type ReactNode } from "react";
2
+ import { type YouAskedUser } from "./client";
3
+ import { type Appearance } from "./theme";
4
+ export declare const DEFAULT_API_URL = "https://api.youasked.dev";
5
+ export type YouAskedProps = {
6
+ /** Publishable key (ya_pub_…). Safe to ship in client code. Not needed with `demo`. */
7
+ appKey?: string;
8
+ /**
9
+ * Runs entirely in the browser with sample requests and a pretend team, no network. Posting, voting,
10
+ * commenting and a reply a few seconds later all work. For docs, Storybook and landing pages.
11
+ */
12
+ demo?: boolean;
13
+ /** Who's asking. Leave out for anonymous visitors. */
14
+ user?: YouAskedUser | null;
15
+ /** hex HMAC-SHA256 of user.id with your secret key, made on your server (see `signUser`). */
16
+ signature?: string | null;
17
+ /** Set false while you're still fetching the signature; the widget waits instead of acting anonymously. */
18
+ ready?: boolean;
19
+ appearance?: Appearance;
20
+ /** "floating" adds a chat-style launcher in the corner. "none" if you use the inline entry points or your own buttons. */
21
+ trigger?: "floating" | "none";
22
+ position?: "bottom-right" | "bottom-left";
23
+ /** Text next to the launcher icon. Leave empty for an icon-only bubble. */
24
+ label?: string;
25
+ /** Your app's name in the greeting. Defaults to the name you created the app with. */
26
+ appName?: string;
27
+ /** Square image URL for your app's icon. By default it's found from the page (apple-touch-icon or a large favicon); false hides it. */
28
+ appIcon?: string | false;
29
+ /** First message on the home screen. */
30
+ greeting?: string;
31
+ /** Heading of the full list. */
32
+ title?: string;
33
+ /** Distance in px from the bottom edge for the launcher, toast and desktop panel, e.g. to clear a tab bar. */
34
+ offset?: number;
35
+ /** Show the corner card for replies, shipped requests and what's new. Turn off for previews embedded in a page. */
36
+ cards?: boolean;
37
+ apiUrl?: string;
38
+ children?: ReactNode;
39
+ };
40
+ export declare function YouAsked({ appKey, demo, cards, user, signature, ready, appearance, trigger, position, label, appName, appIcon, greeting, title, offset, apiUrl, children, }: YouAskedProps): import("react").JSX.Element;