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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shuami-dev/nuxt-session-i18n-theme

v1.0.4

Published

Session, i18n and theme mode package for Nuxt 3

Downloads

297

Readme

Nuxt Session, i18n and Theme

A Nuxt.js package that provides session management, localization (i18n), and theme management functionalities. This package aims to simplify the implementation of user sessions and multilingual support in your Nuxt applications.

Features

  • Session management using sessionStorage.
  • Localization support with dynamic language fetching.
  • Theme management for light and dark modes.
  • Includes global CSS for styling.
  • Share application Id (e.g: event id, project id etc)
  • Share other optional parameter (e.g: optional id)

Installation

To install the package, run the following command:

npm install @shuami-dev/nuxt-session-i18n-theme

Usage

  1. Add to Nuxt Config
    In your nuxt.config.ts, add the package to your CSS array:
export default defineNuxtConfig({
  css: ["@shuami-dev/nuxt-session-i18n-theme/style.css"],
})
  1. Configure i18n and theme
    In your nuxt.config.ts, add the i18n configuration:
export default defineNuxtConfig({
  plugins: ["~/plugins/i18n.ts", "~/plugins/theme.ts"],
})
  1. Create i18n.ts file
    Create i18n.ts file in plugins folder (plugins/i18n.ts):
import { createDynamicI18n } from "@shuami-dev/nuxt-session-i18n-theme"
import en from "~/locales/en.json"
import ms from "~/locales/ms.json"

export default defineNuxtPlugin((nuxtApp) => {
  const i18n = createDynamicI18n({ en, ms }, "yoursessionId")

  nuxtApp.vueApp.use(i18n)
})
  1. Create theme.ts file
    Create theme.ts file in plugins folder (plugins/theme.ts):
import { applyThemeMode } from "@shuami-dev/nuxt-session-i18n-theme"

export default defineNuxtPlugin(() => {
  applyThemeMode("yoursessionId")
})
  1. Create en.json file
    Create en.json file in locales folder (locales/en.json):
{
  "welcome": "Welcome"
}
  1. Create ms.json file
    Create ms.json file in locales folder (locales/ms.json):
{
  "welcome": "Selamat Datang"
}
  1. Using the Package
    Import and use the provided session, i18n and theme utilities in your components:
<script setup lang="ts">
  import { useAppSession } from "@shuami-dev/nuxt-session-i18n-theme"

  const { keyId, appUid, language, themeMode, optId } = useAppSession(
    "yoursessionId",                // Your session storage name
    "username",                     // Your token object name
    "you-optional-id-name"          // Your optional id if you have any. Can remove this parameter if not using it
  )
</script>

<template>
  <div>Page: index</div>
  <div>
    <h1>{{ $t("welcome") }}</h1>
    <p>Key ID: {{ keyId }}</p>
    <p>Project ID: {{ appUid }}</p>
    <p>Current Language: {{ language }}</p>
    <p>Current Theme: {{ themeMode }}</p>
    <p>Optional ID: {{ optId }}</p>
  </div>
</template>

<style scoped></style>