MetaCheck is a web application that allows you to preview how your website links will appear on various social media platforms and search engines. It helps you optimize your website's metadata (Open Graph tags, Twitter Cards, meta title, meta description, favicon) to ensure your links are engaging and informative when shared.
- Multi-Platform Previews: See how your link will look on:
- Telegram
- DuckDuckGo
- Discord
- Mastodon
- Metadata Analysis: Fetches and displays key metadata from your URL, including:
- Title
- Description
- Image
- Favicon
- URL Normalization: Automatically cleans and normalizes input URLs (adds
https://, removes trailing slashes). - Real-time Fetching: Retrieves metadata on demand when you submit a URL.
- Dark/Light Mode: Supports system preference for theme and allows manual toggling.
- Responsive Design: Adapts to different screen sizes for a seamless experience on desktop and mobile.
- Error Handling: Provides clear error messages if metadata fetching fails.
- Framework: Next.js (App Router)
- Language: TypeScript
- Styling: Tailwind CSS, shadcn/ui (for UI components)
- State Management: React Query (for fetching and caching metadata)
- Metadata Fetching: Cheerio (for parsing HTML on the server-side)
- Analytics: PostHog
- Icons: Lucide React
The project is organized within the app directory, following Next.js App Router conventions:
/app
├── actions/
│ └── fetchMetadata.ts # Server action to fetch URL metadata
├── components/
│ ├── previews/ # Individual preview components for each platform
│ │ ├── DiscordPreview.tsx
│ │ ├── DuckDuckGoPreview.tsx
│ │ ├── FacebookPreview.tsx
│ │ ├── GooglePreview.tsx
│ │ ├── LinkedInPreview.tsx
│ │ ├── MastodonPreview.tsx
│ │ ├── TelegramPreview.tsx
│ │ ├── TwitterPreview.tsx
│ │ └── WhatsAppPreview.tsx
│ ├── LinkPreviewerV2.tsx # Main component for the link previewer UI and logic
│ └── ToggleTheme.tsx # Component for switching between light and dark themes
├── fonts/ # Local font files (Geist Sans, Geist Mono)
├── site/
│ └── [domain]/
│ └── page.tsx # Dynamic route for site-specific previews (potential future feature)
├── types/
│ └── metadata.ts # TypeScript types for metadata
├── favicon.ico # Application favicon
├── globals.css # Global CSS styles
├── layout.tsx # Root layout component
├── page.tsx # Main entry page for the application
└── providers.tsx # Client-side providers (PostHog)
/public
└── seo-image.png # Image used for SEO and social sharing of MetaCheck itself
app/page.tsx: The main entry point of the application, rendering theLinkPreviewerV2component.app/components/LinkPreviewerV2.tsx:- Manages the URL input state.
- Handles form submission and triggers metadata fetching using React Query.
- Displays loading states, error messages, and the various platform preview components.
- Implements URL normalization.
- Provides the main UI structure, including header, input form, and footer.
app/actions/fetchMetadata.ts:- A server action responsible for fetching the HTML content of the provided URL.
- Uses
cheerioto parse the HTML and extract relevant metadata (OG tags, Twitter cards, title, description, image, favicon). - Includes error handling and basic user-agent spoofing to improve fetch success rates.
- Integrates with PostHog for analytics on fetch attempts, successes, and failures.
- Preview Components (
app/components/previews/*.tsx):- Each component takes the fetched
metadataas a prop. - Renders a visual representation of how a link would appear on that specific platform, using the metadata.
- Each component takes the fetched
app/layout.tsx:- Sets up global HTML structure, including language and fonts.
- Defines global metadata for the MetaCheck application itself (for SEO and social sharing).
- Includes Vercel Analytics.
app/providers.tsx:- Wraps the application with client-side providers, specifically for PostHog analytics, ensuring page views are tracked correctly.
To run this project locally:
-
Clone the repository:
git clone git@github.com:oyeolamilekan/metacheck.git cd metacheck -
Install dependencies:
npm install # or yarn install # or pnpm install
-
Set up environment variables: Create a
.env.localfile in the root of the project and add your PostHog API key and host if you want to use analytics:NEXT_PUBLIC_POSTHOG_KEY=your_posthog_api_key NEXT_PUBLIC_POSTHOG_HOST=your_posthog_host
If you don't have PostHog keys, the application will still run, but analytics events will not be sent.
-
Run the development server:
npm run dev # or yarn dev # or pnpm dev
-
Open http://localhost:3000 in your browser to see the application.
- The user enters a URL into the input field on the
LinkPreviewerV2component. - On submission, the
handleSubmitfunction normalizes the URL and callsrefetchfrom React Query. - React Query triggers the
fetchMetadataserver action, passing the normalized URL. - The
fetchMetadataaction: a. Makes afetchrequest to the target URL with a specific User-Agent header to mimic a browser. b. If the request is successful, it parses the HTML response usingcheerio. c. It extracts metadata by looking for common meta tags (Open Graph, Twitter, standard meta tags). d. It attempts to find a favicon URL. e. It ensures image URLs are absolute. f. Returns the extracted metadata object. - If
fetchMetadatais successful, React Query updates themetadatastate inLinkPreviewerV2. - The
LinkPreviewerV2component re-renders, and ifmetadatais available, it passes this data to each of the preview components (e.g.,GooglePreview,TwitterPreview). - Each preview component then displays the link information styled according to its respective platform.
- If
fetchMetadataencounters an error (e.g., URL is unreachable, no metadata found), an error message is displayed to the user.
Contributions are welcome! If you have ideas for improvements or find any bugs, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Made by Appstate