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

create-t3svelte-app

v1.1.3

Published

Rapidly setup T3 Stack with SvelteKit

Downloads

7

Readme

Outline

Get Building

✅ Elegant full-stack framework powered by SvelteKit
✅ Static typing support with TypeScript
✅ End-to-end typesafe APIs with tRPC
✅ Enjoyable database interaction with Prisma
✅ Efficient styling with Tailwind CSS

npm

npx create-t3svelte-app@latest

yarn

yarn create t3svelte-app

Prisma Requirements

If you choose not to init DB on first build, you can initialize prisma db at any time by editing the DATABASE_URL in .env and then running npx prisma db pull and npx prisma generate. You can read more about Prisma on their docs.

Available Templates

A simple CLI with highly opinionated, out-of-the-box ready SvelteKit/tRPC/Prisma/Tailwind application. CLI options include 'Standard' and 'Custom' (modular build). Just run and start building.

Standard (Recommended)

  • SvelteKit
  • TypeScript
  • tRPC - preconfigured with example API call in +page.svelte
  • Tailwind CSS - preconfigured with eslint/prettier & 'tailwind prettier plugin' integration
  • Prisma ORM - CLI option to initialize DB on run - no need to run prisma db pull or prisma db generate

Custom (Modular Build)

Tech Stack Options:

  • SvelteKit
  • TypeScript || JavaScript
  • tRPC
  • Tailwind CSS
  • Prisma ORM

Tool Options:

Config Options:

  • Git Init
  • DB Auto Configure w/ Prisma (Postgresql, MySQL, MongoDB, SQLite)
  • Auto Dependency Install

Contributing

See a bug? Want to help? Easiest way is to clone the main repo and run npm link in the cloned directory. You can code and then run create-t3svelte-app in any directory.

git clone https://github.com/zach-hopkins/create-t3svelte-app
cd create-t3svelte-app
npm i
npm link
mkdir test-project
cd test-project
create-t3svelte-app

Run npm unlink create-t3svelte-app to undo.

Caveats & Addendums

Server-Side Rendering

If you need to use the tRPC client in SvelteKit's load() function for SSR, make sure to initialize it like so:

// $lib/trpcClient.ts

import { browser } from '$app/env';
import type { Router } from '$lib/trpcServer';
import * as trpc from '@trpc/client';
import type { LoadEvent } from "@sveltejs/kit";

const url = browser ? '/trpc' : 'http://localhost:3000/trpc';
export default (loadFetch?: LoadEvent['fetch']) =>
  trpc.createTRPCClient<Router>({
    url: loadFetch ? '/trpc' : url,
    transformer: trpcTransformer,
    ...(loadFetch && { fetch: loadFetch as typeof fetch })
  });
  

Then use it like so:

// src/routes/+authors.svelte

import trpcClient from '$lib/trpcClient';
import type { Load } from '@sveltejs/kit';

export const load: Load = async ({ fetch }) => { // 👈 make sure to pass in this fetch, not the global fetch
	const authors = await trpcClient(fetch).query('authors:browse', {
		genre: 'fantasy',
	});
	return { props: { authors } };
};

Vercel's Edge Cache for Serverless Functions

Your server responses must satisfy some criteria in order for them to be cached on Vercel's Edge Network. tRPC's responseMeta() comes in handy here since you can initialize your handle in src/hooks.server.ts like so:

// src/hooks.server.ts

import { router } from '$lib/trpcServer';
import { createTRPCHandle } from 'trpc-sveltekit';

export const handle = async ({ event, resolve }) => {
  const response = await createTRPCHandle({
    url: '/trpc',
    event,
    resolve,
    responseMeta({ type, errors }) {
      if (type === 'query' && errors.length === 0) {
        const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
        return {
          headers: {
            'cache-control': `s-maxage=1, stale-while-revalidate=${ONE_DAY_IN_SECONDS}`
          }
        };
      }
      return {};
    }
  });

  return response;
};

Shoutouts

License

MIT