Minimal, zero-configuration and fast solution for static site generation in any front-end framework.

Overview

Static-it

Staticit - Introduction

Whether you want to increase performance of your web application or improve SEO. Generally you have 2 options, use SSR (Server Side Rendering) or SSG (Static Site Generation). SSR can be cumbersome and you will need a server to host it.

SSG is relatively simple and a good alternative. Some frameworks have this feature out of the box some don't, some are bloated and you may want a simpler solution. Here comes the Staticit!

Staticit is a improved version of a small library called react-spa-prerender. Under the hood it uses sifrr and puppeteer to generate static files.

Since it's standalone it will work with any build tool and any front-end framework that supports routing.

How it works?

  • Serves the web application from build directory with sifrr.
  • Renders & generates desired routes with puppeteer.
  • Reformats all generated HTML files with prettier so they'll be pretty 🥰 .

Install

- Latest LTS Node.js is recommended.

  • With npm:
$ npm install -D staticit
  • With yarn:
$ yarn add --dev staticit
  • With pnpm:
$ pnpm install -D staticit

Usage

Create a file called .staticit.json in your project root directory. For minimal configuration add the following lines.

{
  "routes": ["/", "/about"],
  "outDir": "./dist",
  "port": 8080
}

- If you are going to build your application in an automated environment, for example with a CI tool. You should pass the --no-sandbox flag to puppeteer: launchOpts or you might get errors since most of them are running inside of a container with root user. (Ref)

"scripts": {
  ...
  "postbuild": "staticit"
}

References

JSON Reference

Option Default Description
routes [] Array of routes that you want to pre-render & generate static files.
outDir ./dist Relative path to the build directory of your application.
port 8080 The port where the static server will serve your web application for the puppeteer.
puppeteer: launchOpts {} Generic launch options that can be passed when launching puppeteer browser.
puppeteer: waitForOpts {} Timeout options for puppeteer browser.

--

CLI Reference

Option Description
--disable-prettier Disables formatting HTML files with prettier.
-c, --config To use with different config file name.

Examples

License

This repository is licensed under the MIT License.

You might also like...

Production-ready fullstack Nuxt 3 starter with a well-working, opinionated configuration

Production-ready fullstack Nuxt 3 starter with a well-working, opinionated configuration

sidebase sidebase is a modern, best-practice, batteries-included fullstack-app starter based on Nuxt 3 and TypeScript. With this nuxt 3 starter you ge

Jan 1, 2023

:bento: Full-Stack solution to quickly build PWA applications with Vue.js and Firebase

:bento: Full-Stack solution to quickly build PWA applications with Vue.js and Firebase

Welcome to bento-starter 👋 🍱 bento-starter is an Open-Source Full-Stack solution that helps you to build fast and maintainable web applications usin

Dec 24, 2022

:fire::fire::fire: 强大的动态表单生成器|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON.

:fire::fire::fire: 强大的动态表单生成器|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON.

form-create form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions thr

Jan 3, 2023

⚡️ Integrate Nuxt with Twind, The smallest, fastest, most feature complete tailwind-in-js solution in existence!

Nuxt Twind Module Integrate Nuxt with Twind, The smallest, fastest, most feature complete tailwind-in-js solution in existence! Warning 🧪 This module

Oct 18, 2022

Easy generation of OpenGraph & Twitter meta-tags in Nuxt 3 📋

nuxt-social-tags Easy generation of OpenGraph & Twitter meta-tags in Nuxt 3 ✨ Release Notes 📖 Read the documentation Features Nuxt3 ready Composables

Dec 17, 2022

A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

Azure Static Web App Template with Node.js API This is a template repository for creating Azure Static Web Apps that comes pre-configured with: Vue.js

Jun 25, 2022

⚡A zero-config bundler for JavaScript applications.

⚡A zero-config bundler for JavaScript applications.

Poi is a bundler built on the top of webpack, trying to make developing and bundling apps with webpack as easy as possible. The Poi project is support

Jan 4, 2023

A zero-dependencies script to generate sponsors SVG from Patreon

sponsors A zero-dependencies script to generate sponsors SVG from Patreon. Usage Go to https://www.patreon.com/portal/registration/register-clients to

Apr 25, 2022

A modern, zero-dependency uptime monitoring tool & status page based on GitHub Actions & Nuxt Content v2.

A modern, zero-dependency uptime monitoring tool & status page based on GitHub Actions & Nuxt Content v2.

StatusBase Uptime monitoring tool & beautiful status pages Powered by Nuxt Content v2! Free • Open Source • Notification View Demo · Report Bug · Requ

Dec 27, 2022
Comments
  • Err: Invalid access of discarded(invalid, deleted) uWS.HttpResponse/SSLHttpResponse

    Err: Invalid access of discarded(invalid, deleted) uWS.HttpResponse/SSLHttpResponse

    Hey there,

    first of all I would like to compliment you for having thought of this workaround that eases integrating pre-rendered static sites in frontend frameworks.

    Stack:

    • Vue 3 + Vite (Scaffolded using Vite CLI)
    • Node 16
    • M1 Macbook Air 2020

    Now onto the issue: I am trying to static-ify a bunch of routes in my frontend project. But sadly there is this following error that appears in 80% of cases:

    image

    The special thing about this is, that it works some of the time. Most of the time it does not.

    Cheers and keep up the good work!

    good first issue 
    opened by RayNCooper 3
Owner
Engineerhub
We're group of engineers and old time friends from Turkey.
Engineerhub
⚡️ Minimal GraphQL Client + Code Generation for Nuxt

nuxt-graphql-client ⚡️ Minimal GraphQL Client + Code Generation for Nuxt ⚡️ Minimal GraphQL Client + Code Generation for Nuxt Features Zero Configurat

Dizzy 245 Dec 27, 2022
⚡️ Minimal GraphQL Client + Code Generation for Nuxt3

nuxt-graphql-client ⚡️ Minimal GraphQL Client + Code Generation for Nuxt ⚡️ Minimal GraphQL Client + Code Generation for Nuxt Documentation Features Z

Conrawl Rogers 245 Dec 27, 2022
📝 Minimalistic Vue-powered static site generator

VuePress 2 is coming! Please check out vuepress-next. Documentation Check out our docs at https://vuepress.vuejs.org/. Showcase Awesome VuePress vuepr

vuejs 21.1k Jan 4, 2023
Adapter for SvelteKit apps that prerenders your site as a collection of static files for GitHub Pages

svelte-adapter-github Adapter for SvelteKit apps that prerenders your site as a collection of static files for GitHub Pages. Usage Install with npm i

null 36 Sep 20, 2022
Next generation frontend tooling. It's fast!

Vite ⚡ Next Generation Frontend Tooling ?? Instant Server Start ⚡️ Lightning Fast HMR ??️ Rich Features ?? Optimized Build ?? Universal Plugin Interfa

vite 51.2k Jan 5, 2023
Cryptomator.js is a Cryptomator implementation in JavaScript/Typescript with a Vuetify front end.

Cryptomator.js is a Cryptomator implementation in JavaScript/Typescript with a Vuetify front end. No dedicated back end is needed as the complete application runs natively in the browser.

Marc Boeker 9 Nov 16, 2022
Template for front-end projects

⚡ vite-super-ssr template This template repo tries to achieve the minimum viable example for a modern front-end application The list of features: ✅ Vi

Dmitrii 19 Dec 26, 2022
End-to-end typesafe APIs with tRPC.io in Nuxt applications.

tRPC-Nuxt End-to-end typesafe APIs with tRPC.io in Nuxt applications. The client above is not importing any code from the server, only its type declar

Robert Soriano 231 Dec 30, 2022
Automatically configure Vitest from your SvelteKit configuration.

vitest-svelte-kit Automatically configure Vitest from your SvelteKit configuration. Getting Started Installing In an existing SvelteKit project, run t

Nick Breaton 44 Dec 30, 2022