Best way to include fonts?
I am importing
on
__root
but this leads to the font not being available in stack. What is the recommended way to use fonts?
thanks!12 Replies
adverse-sapphireOP•3mo ago
There is this guide, but moving the import to the css does not fix the issue:
https://tanstack.com/start/latest/docs/framework/react/migrate-from-next-js#fonts
Migrate from Next.js | TanStack Start React Docs
[!IMPORTANT] This guide is based on the upcoming work in the alpha branch of TanStack Start. We are actively working on exciting new features, and this guide will be updated soon. This guide provides...
adverse-sapphireOP•3mo ago
For now Im fixing it like this:
but this feels very brittle, and annoying to mantain, since it will break with every release of the font
ratty-blush•3mo ago
why you dont use tailwindcss and css ?
adverse-sapphireOP•3mo ago
Loading the fonts from google is somewhat sketchy since it gives google information I'd prefer not to give if I can avoid. IE, I prefer to self host my fonts
Using the self hosted fonts in CSS / tailwind, leads to the same error.
ratty-blush•3mo ago
btw there is also: https://github.com/unjs/fontaine
What happens if you place the fonts in "public/fonts" for example? It should correctly resolve i think
adverse-sapphireOP•3mo ago
yes, but i would have to download them, and not rely on npm. I'm happy to leave someone that responsability 😅
ratty-blush•3mo ago
I mean, fonts dont really change that often for that effort tbh :p
passive-yellow•3mo ago
I'm importing the font from fontsource in the
__root.tsx
file and its working. I tried also with tailwind, no issueadverse-sapphireOP•3mo ago
are you already devinxed?
passive-yellow•3mo ago
yes I tried on a fresh install
adverse-sapphireOP•3mo ago
I see, wonder what im doing wrong
or missing
passive-yellow•3mo ago
This is all I'm doing to make it work: