Frameworks
A custom element is just a DOM element, so there is no wrapper package to install and nothing to keep in step with your framework’s release cycle. The only thing that differs between frameworks is how you set a property that isn’t a string.
<script type="module"> import 'fileon';</script>
<file-preview src="/report.pdf" name="Q3 report.pdf" bordered></file-preview>import { useEffect, useRef } from 'react';import 'fileon';
export function Preview({ file }) { const ref = useRef(null);
// Assign as a property: React would stringify a File into an attribute. useEffect(() => { if (ref.current) ref.current.file = file; }, [file]);
return <file-preview ref={ref} bordered style={{ '--fp-min-height': '520px' }} />;}A plain URL can go straight on as an attribute, with no effect needed:
<file-preview src={url} bordered /><template> <file-preview :src="url" bordered /></template>
<script setup>import 'fileon';defineProps({ url: String });</script>Tell the compiler these tags are custom elements, or it will warn on every render:
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('file-preview') }, },});<script> import 'fileon'; export let file;
let el; $: if (el) el.file = file;</script>
<file-preview bind:this={el} bordered></file-preview>import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';import 'fileon';
@Component({ selector: 'app-preview', standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: `<file-preview [attr.src]="url" bordered></file-preview>`,})export class PreviewComponent { url = '/report.pdf';}Server-side rendering
Section titled “Server-side rendering”The package touches document at import time to register the elements, so import it in a
client-only path: a useEffect, an onMount, a dynamic import(), or Astro’s
client:only. The markup itself is inert until the definition arrives, so the page will not
flash broken content.
// Next.js app router'use client';import { useEffect } from 'react';
useEffect(() => { import('fileon');}, []);