npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-fileapp

v0.0.15

Published

Svelte file application

Downloads

30

Readme

svelte-fileapp

A lightweight Svelte 5 library for building file-based applications with routing, SSG (Static Site Generation), and advanced URL management.

Features

  • 🚀 File-based Routing - Simple and intuitive routing system with hash or history mode
  • 📦 Static Site Generation - Built-in SSG support with jsonjsdb integration
  • 🔗 Advanced URL Management - Comprehensive URL parameters and hash handling
  • 🎯 App Bootstrap - Smart hydration and mounting for SPA and static apps
  • 📱 Browser Utilities - Device detection and responsive helpers
  • Vite Plugins - Custom Vite plugins for optimization

Installation

npm install svelte-fileapp

Quick Start

Basic App Bootstrap

import { bootstrapApp } from 'svelte-fileapp'
import App from './App.svelte'

// Simple bootstrap
await bootstrapApp(App)

// With custom target and initialization
await bootstrapApp(App, 'app', async () => {
  // Your initialization logic
  console.log('App initializing...')
})

URL Management

import { UrlParam, UrlHash } from 'svelte-fileapp'

// Get URL parameters
const value = UrlParam.get('search')

// Set URL parameters
UrlParam.set('filter', 'active')

// Delete parameters
UrlParam.delete('filter')

// Reset all parameters
UrlParam.reset()

// Get all parameters
const allParams = UrlParam.getAllParams()

// Hash management
const currentHash = UrlHash.getAll()
const level1 = UrlHash.getLevel1() // First segment
const level2 = UrlHash.getLevel2() // Second segment

Router Setup

import { router } from 'svelte-fileapp'

// Navigate programmatically
router.navigate('/home')

// Use in HTML with helper
window.goToHref(event, '/about')

Browser Utilities

import {
  isMobile,
  isFirefox,
  hasTouchScreen,
  isSmallMenu,
} from 'svelte-fileapp'

if (isMobile) {
  // Mobile-specific logic
}

// Reactive store for responsive layouts
isSmallMenu.subscribe(isSmall => {
  console.log('Small menu:', isSmall)
})

Vite Configuration

Using Vite Plugins

// vite.config.ts
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import {
  updateRouterIndex,
  htmlReplace,
  spaHtmlOptimizations,
  getAliases,
} from 'svelte-fileapp'

export default defineConfig({
  plugins: [
    svelte(),
    updateRouterIndex(),
    htmlReplace(),
    spaHtmlOptimizations(),
  ],
  resolve: {
    alias: getAliases(import.meta.url),
  },
})

Static Site Generation

Basic SSG

import { generateStaticSite } from 'svelte-fileapp'

await generateStaticSite({
  routes: ['/', '/about', '/contact'],
  outDir: 'dist',
})

Jsonjsdb SSG

import { generateJsonjsdbStaticSite } from 'svelte-fileapp'

await generateJsonjsdbStaticSite({
  dbPath: './data',
  outDir: 'dist',
  entities: ['posts', 'users'],
})

API Reference

App Bootstrap

bootstrapApp(AppComponent, targetId?, initFn?)

Bootstraps a Svelte application with smart hydration support.

  • AppComponent: The root Svelte component
  • targetId: Target element ID (default: 'app')
  • initFn: Optional async initialization function

URL Management

UrlParam Class

  • get(key) - Get URL parameter value
  • set(key, value) - Set URL parameter
  • delete(key) - Delete URL parameter
  • reset() - Reset all parameters
  • getAllParams() - Get all parameters as object
  • getAppMode() - Get current app mode (spa/static_render/check_db)

UrlHash Class

  • getAll() - Get complete hash value
  • getLevel1() - Get first segment of hash
  • getLevel2() - Get second segment of hash
  • default - Default hash value ('homepage')

Browser Utilities

Constants

  • isFirefox - Boolean for Firefox detection
  • isMobile - Boolean for mobile detection
  • hasTouchScreen - Boolean for touch screen detection
  • documentWidth - Current document width

Stores

  • isSmallMenu - Writable store for responsive menu state

App Modes

The library supports three app modes:

  1. SPA (default) - Single Page Application with hash routing
  2. static_render - Static site generation mode
  3. check_db - Database check mode

Mode is automatically detected from:

  • URL parameter app_mode
  • Meta tag <meta app-mode="static">

Router Helpers

import {
  getInitialPage,
  getInitialComponent,
  updateRouteComponent,
} from 'svelte-fileapp'

// Get initial page based on static mode
const initialPage = getInitialPage(routerIndex, '_loading')

// Get component with hydration support
const component = getInitialComponent(routerIndex, initialPage, '_loading')

Development

# Install dependencies
npm install

# Build library
npm run build

# Run tests
npm test

# Lint code
npm run lint

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.