PWA Example with Next.js, React, TypeScript, Tailwind CSS, Radix UI, and OneSignal

 

 

This project is a Progressive Web App (PWA) built with Next.js, React, and TypeScript. It uses Tailwind CSS for styling, Radix UI for accessible components, OneSignal for push notifications, and demonstrates access to the file system and webcam.

Installation

 

To get started with this project, clone the repository and install the dependencies:

git clone https://github.com/UbyXsofT/my-pwa-app.git
cd my-pwa-app
npm install

Development

 

To start the development server, run:

npm run dev

This will start the application in development mode at http://localhost:3000.

Build

 

o build the application for production, run:

npm run build

Features

 

  • Progressive Web App (PWA): Offline support and installable on devices.
  • Next.js: Server-side rendering and static site generation.
  • React & TypeScript: Modern – JavaScript framework with static typing.
  • Tailwind CSS: Utility-first CSS framework for rapid UI development.
  • Radix UI: Accessible, unstyled UI component library.
  • OneSignal: Push notifications.
  • File System Access: Demonstrates access to the file system.
  • Webcam Access: Demonstrates access to the webcam.

Usage

 

OneSignal Push Notifications

 

To set up OneSignal for push notifications, follow these steps:

1 – Download and unzip the OneSignal SDK: OneSignalSDK-v16-ServiceWorker.zip

2 – Add the unzipped files to the public directory of your project.

3 – Modify the _document.tsx to include OneSignalSDK:

//_document.tsx
import { Html, Head, Main, NextScript } from "next/document";

export default function Document() {
	return (
		<Html lang='en'>
			<Head>
				<link
					rel='manifest'
					href='/manifest.json'
				/>
				<link
					rel='apple-touch-icon'
					href='/icon.png'
				/>
				<meta
					name='theme-color'
					content='#fff'
				/>
				<script
					src='https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js'
					async
				></script>
			</Head>
			<body>
				<Main />
				<NextScript />
			</body>
		</Html>
	);
}

4 – Initialize OneSignal in src/functions/onesignal.js:

//src/functions/onesignal.js
import OneSignal from "react-onesignal";

export default async function runOneSignal() {
	console.log("Inizializzazione OneSignal");
	try {
		await OneSignal.init({
			appId: "YOUR-ONESIGNAL-APP-ID",
			allowLocalhostAsSecureOrigin: true,
			serviceWorkerParam: {
				scope: "/",
				path: "/OneSignalSDKWorker.js",
			},
		});
		console.log("OneSignal inizializzato");
		OneSignal.Slidedown.promptPush();
		console.log("Prompt mostrato");
	} catch (error) {
		console.log("ONESIGNAL ERROR: ", error);
	}
}

5 – Call runOneSignal in src/pages/_app.tsx:

import "../src/styles/globals.css";
import { AppProps } from "next/app";
import { useEffect } from "react";
import runOneSignal from "../src/functions/onesignal";

function MyApp({ Component, pageProps }: AppProps) {
  useEffect(() => {
    runOneSignal();
  }, []);

  return <Component {...pageProps} />;
}

export default MyApp;

File System Access

 

To use the File System Access API, you can create a component that allows users to pick a file and read its content. Here’s an example of a file picker component:

import { ReactNode, useState } from "react";

const FileSystemComponent = () => {
	const [fileContent, setFileContent] = useState<string | ArrayBuffer | null>("");
	const handleFilePick = async () => {
		const [fileHandle] = await (window as any).showOpenFilePicker();
		const file = await fileHandle.getFile();
		const text = await file.text();
		setFileContent(text);
	};

	return (
		<div>
			<button
				style={{ margin: "20px" }}
				onClick={handleFilePick}
			>
				Pick a file
			</button>
			<pre>{fileContent as ReactNode}</pre>
		</div>
	);
};

export default FileSystemComponent;

Webcam Access

 

To access the webcam, you can create a component that uses the MediaDevices API. Here’s an example of a webcam component:

import React, { useRef, useEffect } from "react";

const CameraComponent: React.FC = () => {
	const videoRef = useRef<HTMLVideoElement>(null);

	useEffect(() => {
		const startCamera = async () => {
			if (videoRef.current) {
				try {
					const stream: MediaStream = await navigator.mediaDevices.getUserMedia({ video: true });
					if (videoRef.current) {
						videoRef.current.srcObject = stream;
					}
				} catch (err) {
					console.error("Error accessing camera: ", err);
				}
			}
		};

		startCamera();
	}, []);

	return (
		<video
			ref={videoRef}
			autoPlay
			style={{ width: "100%", height: "200px" }}
		/>
	);
};

export default CameraComponent;

Contributing

 

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project’s code of conduct, please feel free to submit a pull request.

License

 

This project is licensed under the MIT License. See the LICENSE file for details.

Here is the source code project on GitHub

 

Kontakt Library Fix X1 edition

cross platform for windows, macOs, and Linux!

Kontakt Library Fix is an Free Utility created by me Ubaldo Formichetti which helps importing non-native libraries, in kontakt. That creates the configuration file of the non-native Kontakt library, with a random id or insert id, to avoid duplication problems when registering in the registry, allows the creation of the appropriate library wallpaper, adapting .jpg and .png files. in this new version, there is included a good image editor that gives us the possibility to import an image as a background and then change it by entering text and other graphic elements, you don’t need any other graphic software, to create your banner. – Resolves the problem of the “no library found kontakt” error during the import. In an easy and creative way. Works with full versions of Kontakt (No Kontakt player) from ver. 5.5.8 +

Kontakt Library Fix è un’utilità gratuita creata da me, Ubaldo Formichetti, che aiuta nell’importazione di librerie non native in Kontakt. Questo programma crea il file di configurazione della libreria non nativa di Kontakt, assegnando un ID casuale o personalizzato per evitare problemi di duplicazione durante la registrazione nel registro. Consente anche di creare lo sfondo appropriato per la libreria, adattando file .jpg e .png. In questa nuova versione è incluso un ottimo editor di immagini che ci permette di importare un’immagine come sfondo e successivamente modificarla aggiungendo testo e altri elementi grafici; non è necessario alcun altro software grafico per creare il proprio banner. Risolve in modo semplice e creativo il problema dell’errore “nessuna libreria trovata in Kontakt” durante l’importazione. Funziona con le versioni complete di Kontakt (non con Kontakt Player) dalla versione 5.5.8 in poi.

To unlock the KLF app (red lock icon), registration in our forum of vivo-vivendo-musica.com is required, if you are an already registered user click on the lock icon and enter your username and email , with which you registered on the VVM forum, and the KLF app will be unlocked forever (beware you don’t have an infinite number of devices on which to install this app, so please don’t give your credentials to other people). Register in: vivo-vivendo-musica.com

Per sbloccare l’app KLF (icona lucchetto rosso), è necessaria la registrazione nel nostro forum su vivo-vivendo-musica.com. Se sei già registrato, clicca sull’icona del lucchetto e inserisci il tuo nome utente e indirizzo email con cui ti sei registrato sul forum di VVM. L’app KLF verrà sbloccata per sempre. Tieni presente che non hai un numero infinito di dispositivi su cui installare questa app, quindi per favore non condividere le tue credenziali con altre persone. Registrati su: vivo-vivendo-musica.com.

Click here to download Kontakt Library Fix x1 edition

If you like it Kontakt Library Fix X1 Edition, consider offering a coffee, it will be highly appreciated, THANK YOU!