Icons & Favicons
Favicons, Apple touch icons, and web manifest icons - defined in metadata.icons and injected by bini-ssg.
Overview
Icons cover browser tabs, bookmarks, iOS home screen, and Android / PWA install. Define them with metadata.icons. bini-ssg injects route-specific icons with the correct type and sizes.
- Favicons:
icon,shortcut- SVG and ICO with sizes - Apple Touch:
apple- 180×180 for iOS home screen - Manifest:
manifestfield +public/site.webmanifest - Defaults: drop files in
public/- no extra config required
Icon Types
| Field | Injected as | Description |
|---|---|---|
| icon | link rel=icon | Standard favicon with type and sizes |
| shortcut | link rel=shortcut icon | Legacy shortcut icon |
| apple | link rel=apple-touch-icon | iOS home screen - 180×180 recommended |
| other | link | Other link tags e.g. mask-icon |
Icon object fields
| Field | Type | Description |
|---|---|---|
| url | string | URL to icon file |
| type | string | MIME type e.g. image/svg+xml |
| sizes | string | Size e.g. 32x32, 180x180 |
| rel | string | Optional rel override |
Favicons
Prefer SVG for modern browsers, with PNG and ICO as fallbacks.
export const metadata = {
title: 'My App',
icons: {
icon: [
{ url: '/favicon.svg', type: 'image/svg+xml' },
{ url: '/favicon.ico' },
{ url: '/favicon-32x32.png', sizes: '32x32', type: 'image/png' },
{ url: '/favicon-16x16.png', sizes: '16x16', type: 'image/png' },
],
shortcut: '/favicon.ico',
},
}| File | Size | Purpose |
|---|---|---|
| favicon.svg | any | Modern browsers - scalable |
| favicon.ico | 32×32 | Legacy fallback |
| favicon-32x32.png | 32×32 | Standard tab icon |
| favicon-16x16.png | 16×16 | Small tab icon |
Apple Touch Icons
Used when a user adds your site to the iOS home screen. iOS applies rounded corners unless you supply a precomposed asset.
export const metadata = {
icons: {
apple: [
{
url: '/apple-touch-icon.png',
sizes: '180x180',
type: 'image/png',
},
],
},
}apple-touch-icon.png in public/ also works for automatic detection.SVG vs ICO
- SVG: vector, scalable, can use
prefers-color-scheme - ICO: multi-size bitmap container for legacy browsers
- PNG: widely supported middle ground
- Best practice: SVG + 32×32 PNG + ICO + 180×180 Apple
export const metadata = {
icons: {
icon: [
{ url: '/favicon.svg', type: 'image/svg+xml' },
{ url: '/favicon.ico', sizes: '32x32' },
],
},
}Manifest & Icons
The web app manifest supplies icons for Android home screen, splash, and PWA install.
export const metadata = {
manifest: '/site.webmanifest',
themeColor: '#0a0a0a',
}{
"name": "My Bini.js App",
"short_name": "Bini",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#0a0a0a",
"background_color": "#ffffff",
"display": "standalone"
}Default Images
Put assets in public/. Replace the defaults with your own files.
logo.png in public/ is often used as the source icon for platform icon generation.bini-ssg Injection
During vite build, bini-ssg injects icons into pre-rendered HTML. Matching rel tags are updated in place.
| Source | Injected as |
|---|---|
| metadata.icons.icon | link rel=icon |
| metadata.icons.apple | link rel=apple-touch-icon |
| metadata.icons.shortcut | link rel=shortcut icon |
| metadata.manifest | link rel=manifest |
| public/ defaults | Preserved from dist/index.html |
Complete Example
export const metadata = {
title: 'My Bini.js App',
description: 'Built with Bini.js',
manifest: '/site.webmanifest',
themeColor: '#0a0a0a',
icons: {
icon: [
{ url: '/favicon.svg', type: 'image/svg+xml' },
{ url: '/favicon.ico', sizes: '32x32' },
{
url: '/favicon-32x32.png',
sizes: '32x32',
type: 'image/png',
},
{
url: '/favicon-16x16.png',
sizes: '16x16',
type: 'image/png',
},
],
shortcut: '/favicon.ico',
apple: [
{
url: '/apple-touch-icon.png',
sizes: '180x180',
type: 'image/png',
},
],
},
openGraph: {
images: ['/og-image.png'],
},
twitter: {
images: ['/og-image.png'],
},
}