Import From NPM
Aleph.js uses ESM imports syntax. To import modules from NPM, you can use esm.sh (recommended), skypack, or jspm:
import useSWR from "https://esm.sh/swr";
export default function About() {
const { data, error } = useSWR("/api/user", fetcher);
if (error) {
return <div>failed to load</div>;
}
if (!data) {
return <div>loading...</div>;
}
return <div>hello {data.name}!</div>;
}