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

nuxt-subdomains

v1.0.4

Published

A single Nuxt3 application to handle multiple subdomains

Downloads

15

Readme

Nuxt Subdomains

NPM Version License

SampleQuick StartLicenseChangelog

This is a stripped down version of nuxt-multi-tenancy that requires little to no setup. Heavily inspired by zernonia/keypress open-source blogging website.

Why should you use it?

  • Create multiple applications under subdomains in a single Nuxt3 application.
  • Directory based subdomain routing.
  • Little to no setup required.

Quick Start

Installation (Nuxi CLI)

Install the module to your Nuxt application with one command:

npx nuxi module add nuxt-subdomains
# OR
pnpm dlx nuxi module add nuxt-subdomains
# OR
bunx nuxi module add nuxt-subdomains

Installation (Manual)

Add nuxt-subdomains as a dependency to your project.

npm install nuxt-subdomains
# OR
pnpm add nuxt-subdomains
# OR
bun add nuxt-subdomains

And register the module in nuxt.config.ts:

export default defineNuxtConfig({
  modules: [
    // Any other modules,
    "nuxt-subdomains",
  ],
});

Configuration

You need to tell nuxt-subdomains all your main domains of your application. Edit your nuxt.config.ts file:

export default defineNuxtConfig({
  modules: [
    // Any other modules,
    "nuxt-subdomains",
  ],
  nuxtSubdomains: {
    mainDomains: ["localhost:3000", "example.com"],
  },
});

Creating Subdomains

[!IMPORTANT]

You must enable page-based routing in your nuxt application, i.e. there must be a pages directory with your application files.

To create subdomains, you should add a folder preffixed with $ just under your pages directory:

.
├── nuxt.config.ts
├── package.json
├── pages
│   ├── $admin # admin subdomain directory.
│   │   ├── index.vue
│   │   └── [slug].vue
│   ├── admin # /admin route of main domain.
│   │   └── index.vue
│   ├── index.vue
│   ├── $my # my subdomain directory.
│   │   ├── index.vue
│   │   └── [slug].vue
│   └── [slug].vue
├── server
│   └── tsconfig.json
└── tsconfig.json

Run Sample Project

Reproduce the playground code to experiement with the application.

  1. Clone this repository.
  2. Install the dependencies e.g. bun install.
  3. Generate the type stubs e.g. bun run dev:prepare.
  4. Start the local dev server e.g. bun run dev.