grain.social is a photo sharing platform built on atproto.
grain.social
atproto
photography
appview
1export async function share(
2 url: string,
3): Promise<{ success: boolean; method: "share" | "clipboard" }> {
4 if (navigator.share) {
5 try {
6 await navigator.share({ url });
7 return { success: true, method: "share" };
8 } catch (err: any) {
9 if (err.name === "AbortError") {
10 return { success: false, method: "share" };
11 }
12 }
13 }
14
15 try {
16 await navigator.clipboard.writeText(url);
17 return { success: true, method: "clipboard" };
18 } catch {
19 return { success: false, method: "clipboard" };
20 }
21}