
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
google-webfonts-client
Advanced tools
Typesafe and straightforward fetch client for interacting with the Google Web Fonts API using feature-fetch
Status: Experimental
google-webfonts-client is a typesafe and straightforward fetch client for interacting with the Google Web Fonts API using feature-fetch. This client provides typesafe methods for fetching and downloading Google Fonts.
Use createGoogleWebfontsClient() to create a client with your API key.
import { createGoogleWebfontsClient } from 'google-webfonts-client';
const client = createGoogleWebfontsClient({
apiKey: 'YOUR_API_KEY'
});
Fetches the available web fonts from the Google Fonts API.
const webFontsResult = await client.getWebFonts();
const webFonts = webFontsResult.unwrap();
Fetches the URL of a specific font file based on the provided family, weight, and style.
const fontUrlResult = await client.getFontFileUrl('Roboto Serif', {
fontWeight: 400,
fontStyle: 'regular'
});
const fontUrl = fontUrlResult.unwrap();
Use the client to download a font file, specifying the font family, weight, and style.
const fontFileResult = await client.downloadFontFile('Roboto Serif', {
fontWeight: 100,
fontStyle: 'italic'
});
const fontFile = fontFileResult.unwrap();
Errors can occur during API requests, and the client will return detailed error information. Possible error types include:
NetworkError: Indicates a failure in network communication, such as loss of connectivityRequestError: Occurs when the server returns a response with a status code indicating an error (e.g., 4xx or 5xx)FetchError: A general exception type that can encompass other error scenarios not covered by NetworkError or RequestError, for example when the response couldn't be parsed, ..const fontUrlResult = await client.getFontFileUrl('Roboto Serif', {
fontWeight: 400,
fontStyle: 'regular'
});
// First Approach: Handle error using `isErr()`
if (fontUrlResult.isErr()) {
const { error } = fontUrlResult;
if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof RequestError) {
console.error('Request error:', error.message, 'Status:', error.status);
} else if (error instanceof FetchError) {
console.error('Service error:', error.message, 'Code:', error.code);
} else {
console.error('Unexpected error:', error);
}
}
// Second Approach: Unwrap response with `try-catch`
try {
const fontUrl = fontUrlResult.unwrap();
} catch (error) {
if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof RequestError) {
console.error('Request error:', error.message, 'Status:', error.status);
} else if (error instanceof FetchError) {
console.error('Service error:', error.message, 'Code:', error.code);
} else {
console.error('Unexpected error:', error);
}
}
FAQs
Typesafe and straightforward fetch client for interacting with the Google Web Fonts API using feature-fetch
We found that google-webfonts-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.