Custom element for embedding Bluesky profile cards
npm install bluesky-profile-card-embedA custom element for embedding Bluesky profile cards.
```
npm install bluesky-profile-card-embed
then, import the package on your app.
`js
import 'bluesky-profile-card-embed';
import 'bluesky-profile-card-embed/style.css';
import 'bluesky-profile-card-embed/themes/light.css';
`
`html`
target="_blank"
href="https://bsky.app/profile/did:plc:2gkh62xvzokhlf6li4ol3b3d"
class="bluesky-profile-card-fallback"
>
@patak.dev's Bluesky profile
- actor Required allow-unauthenticated
DID or handle of the account
- Optional service-uri
Whether to allow unauthenticated viewing
- Optional https://public.api.bsky.app
URL to an AppView service, defaults to
- loaded error
Fired when the embed has successfully loaded the profile card
-
Fired when the embed fails to load the profile card
The embeds are powered by a static HTML renderer, this renderer can be used directly in your
server-rendering framework of choice for a zero-JS experience.
`tsx
import { fetchProfileCard, renderProfileCard } from 'bluesky-profile-card-embed/core';
import 'bluesky-profile-card-embed/style.css';
import 'bluesky-profile-card-embed/themes/light.css';
// fetch the profile
const controller = new AbortController();
const data = await fetchProfileCard({
actor: did:plc:ragtjsm2j2vknwkz3zp4oxrd,
signal: controller.signal,
});
// render the profile
const html = renderProfileCard(data);
return (
dangerouslySetInnerHTML={{ __html: html }}
>
);
``